Reputation: 3618
How to use locale directory from include package and locale directory in my own project.
My main function
settings = dict(settings)
settings.setdefault('jinja2.i18n.domain', 'mypackage1, mypackage2') #NOT WORK!!!
config.include("mypackage1")
config.add_jinja2_search_path(("mypackage1:templates",
"mypackage2:templates"))
config.add_translation_dirs("mypackage1:locale/",
"mypackage2:locale/")
config.add_jinja2_search_path(("mypackage1:templates",
"mypackage2:templates"))
return config.make_wsgi_app()
Upvotes: 1
Views: 582
Reputation: 12961
You might have misunderstood what the context it. To quote the pyramid glossary :
A string representing the “context” in which a translation was made. For example the word “java” might be translated differently if the translation domain is “programming-languages” than would be if the translation domain was “coffee”. A translation domain is represnted by a collection of .mo files within one or more translation directory directories.
It's not possible to cumulate contexts by setting it to something like 'mypackage1, mypackage2'. What you need to do is make sure that all translation dirs have the same domain, set it in the configuration and call add_translation_dirs
with the multiple dirs.
Upvotes: 2