Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (33 sloc) 1.259 kB
Generate pot translation file using "mytest" as locale domain:
xgettext --language=Python --keyword=_:1,2 -d mytest localedemo.py 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 localefix.py:
#!/usr/bin/env python
# localefix.py
import re
import sys
if __name__ == "__main__":
try:
filename = sys.argv[1]
assert filename != "-"
fd = open(filename)
except:
fd = sys.stdin
line_re = re.compile(r'="([^"]+)"')
for line in fd:
line = line_re.sub(r"=\\1", line)
sys.stdout.write(line)
fd.close()
Merge against existing pot file:
msgmerge old.po mytest.po > new.po
mv new.po mytest.po
Compile:
msgfmt mytest.po -o locale/{lang}/LC_MESSAGES/mytest.mo
Compile files in this demo:
msgfmt mytest_pt_BR.po -o frontend/locale/pt_BR/LC_MESSAGES/mytest.mo
msgfmt mytest_es_ES.po -o frontend/locale/es_ES/LC_MESSAGES/mytest.mo
Jump to Line
Something went wrong with that request. Please try again.