python - Activate Translation in Pyramids -
i want activate translations in pyramids framework. therefore have added translation directorys , set local negotiator in https://stackoverflow.com/a/11289565/2648872 , desribed in http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/i18n.html#default-locale-negotiator. additionally default , available language in ini files set, pyramid wont accept translations. miss activating translations?
greetings
tobias
edit:
snippet of production.ini
[app:main] use = egg:dbas pyramid.reload_templates = true pyramid.debug_authorization = false pyramid.debug_notfound = false pyramid.debug_routematch = false pyramid.default_locale_name = de available_languages = de en
and out of init.py:
def main(global_config, **settings): [...] config = configurator(settings=settings,root_factory='dbas.database.rootfactory') config.add_translation_dirs('locale') [...] config.set_locale_negotiator(my_locale_negotiator)
additionally settings logged, , default_locale_name available_languages visible. unfortunately in my_locale_negotiator, not readable :(
my folder structure like:
dbas |- setup.py |- development.ini |- [...] |-dbas |- __init__.py |- views.py |- [...] |- locale |- dbas.pot |- de |- lc_messages |- dbas.mo |- dbas.po |- en |- lc_messages |- dbas.mo |- dbas.po
pyramid not find translation dirs. according docs need pass absolute directory paths or asset specifications. prefer asset specification, since used view configuration well.
config.add_translation_dirs('dbas:locale')
you not need custom locale negotiator use case since you applying localization-related deployment settings. disable custom locale negotiator in pyramid configuration. rely on pyramid implementation of default locale negotiator.
you need 2 things activate translations. apply these 2 concepts first.
for debugging purpose can use 1 these concepts set locale manually. liked passing locale value in query string. example, visiting
http://my.application?_locale_=de
Comments
Post a Comment