On 31 Mai, 03:06, Douglas Cerna <[email protected]> wrote: > Make sure you specify the i18n namespace and your application domain > in the template. Something like: > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > xmlns:tal="http://xml.zope.org/namespaces/tal" > xmlns:i18n="http://xml.zope.org/namespaces/i18n" > i18n:domain="mypyramidapp">
I have a similar issue. My template looks like this: -- 8< ------------------------------------------- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" metal:use-macro="base" i18n:domain="invoicer"> <tal:block metal:fill-slot="content"> <h3 i18n:translate="">Invoice details for ${invoice.invoicenr}</ h3> <dl> <dt>Customer:</dt> <dd>${invoice.customer.name} (${invoice.customer.customertype})</ dd> </dl> </tal:block> </html> -- 8< ------------------------------------------- The request locale is initialized in a event subscriber: -- 8< ------------------------------------------- from pyramid.events import NewRequest from pyramid.events import subscriber @subscriber(NewRequest) def set_request_locale(event): request = event.request from pyramid.threadlocal import get_current_registry settings = get_current_registry().settings languages = settings['available_languages'].split() for lang in request.accept_language.best_matches(): if lang in languages: request._LOCALE_ = lang break else: request._LOCALE_ = settings['default_locale_name'] -- 8< ------------------------------------------- The translation of strings that are defined in Python code and translated using get_localizer(request).translate(_('Customers')) works correctly. _ is initialized as _ = TranslationStringFactory('invoicer'). Any help would be appreciated. Regards Jan Dittberner -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. 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/pylons-discuss?hl=en.
