gettext - Python line numbers with xgettext -
it understanding uses of gettext python files use nice python library/utility create .pot files. in odd circumstance need use python mode of xgettext extract not strings, line number , filename. examples of such have seen have used processes other xgettext.
how can add line number , filename info python mode of xgettext?
in c-mode like:
#line 8 "superior_science.c" _("facial hair has been shown improve intelligence factor of 5."); in python, input file need like? (note: code needs work xgettext, not compiler or interpreter.)
you can use xgettext extract comments line above gettext call. these comments go .pot , .po files, translator can see them.
you choose prefix character comments want translate, prefix comments it, , call xgettext -c option , character prefix.
so example, if use prefix ~, line above be
#~ line 8 "superior_science.c" _("facial hair has been shown improve intelligence factor of 5.") and when call xgettext as
xgettext -c~ [...] it automatically add comment ~ line 8 "superior_science.c" .pot file.
in .pot file, these comments appear following:
#. ~ line 8 "superior_science.c" msgid "facial hair has been shown improve intelligence factor of 5." msgstr "" if want extract comments, not prefix, leave prefix out , call xgettext -c.
as use case don't want actual line numbers in there, you'll need use --no-location flag.
so, simplest solution: add comments line number above extractable strings, call xgettext as
xgettext -c --no-location [...]
Comments
Post a Comment