It's interesting to see your solutions with i18n. I use translation tag
with Jinja2 and language pack from django since I wanted to leverage
django's translations since they already have a lot of translations in .mo
and .po files so I combined i18 with gettext and jinja2 using google app
engine and the translation library from django:
from django.utils import translation
from django.utils.translation import get_language, activate
from jinja2 import Environment, FileSystemLoader
class DjangoTranslator(object):
def __init__(self):
self.gettext = translation.gettext
self.ngettext = translation.ngettext
self.ugettext = translation.ugettext
self.ungettext = translation.ungettext
class DjangoEnvironment(jinja2.Environment):
def get_translator(self, context):
return DjangoTranslator()
jinja_environment = DjangoEnvironment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.i18n'])
jinja_environment.install_gettext_translations(translation)
What I couldn't get to work were custom filters but there was a workaround
the put my code directly in the filters.py and I'm still working on i18n
for forms validation messages with WTForms. So gettext was my choice to do
localization and I try do like google to enable a hl=<LANGUAGE_CODE> via
HTTP get so many languages get enabled. I use the script
compile-messages.py from django to compile a .po file and it can extend the
.po already provided with the GAE SDK.
Thanks
Niklas
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pocoo-libs/-/P1ShDhVQJmkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.