Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (33 sloc) 1.23 KB
Generate pot translation file using "mytest" as locale domain:
xgettext --language=Python --keyword=_:1,2 -d mytest frontend/template/*
When using translatable strings in templates, variable arguments must be
placed outside of the _() function. Example:
_("foobar %s" % x) # wrong
_("foobar %s") % x # correct
If xgettext fails parsing html elements like this:
<input type="submit" value="{{ _('bla') }}" />
Try --language=Php, or pipe it to
#!/usr/bin/env python
import re
import sys
if __name__ == "__main__":
filename = sys.argv[1]
assert filename != "-"
fd = open(filename)
fd = sys.stdin
line_re = re.compile(r'="([^"]+)"')
for line in fd:
line = line_re.sub(r"=\\1", line)
Merge against existing pot file:
msgmerge old.po mytest.po > new.po
mv new.po mytest.po
msgfmt mytest.po -o locale/{lang}/LC_MESSAGES/
Compile files in this demo:
msgfmt mytest_pt_BR.po -o frontend/locale/pt_BR/LC_MESSAGES/
msgfmt mytest_es_ES.po -o frontend/locale/es_ES/LC_MESSAGES/
Jump to Line
Something went wrong with that request. Please try again.