Custom Templates and Internationalization

Hey,

when using customized templates for indico sites, we might end up with custom strings that should be translated. In the standard indico translation environment, the custom templates are not considered. As it is not a template in a plugin, it will neither be considered there.

Is there a way to translate these “new” strings?

Best,
Markus

Unfortunately not.

As of 2.2 plugins can provide their own template customization folder, but I don’t think plugin translations will work there, since those templates don’t run in the “context” of the plugin, and thus access only the core translations…

Do you know whether it is possible to declare the context (i.e. translation domain) explicitly in the customized template to handle it in a dummy plugin?

No, {% trans %} in Jinja doesn’t support that.

One slightly ugly workaround could be registering a custom jinja plugin that defines a {% plugin XXX %}{% endplugin %} tag, which pushed a plugin context for the specified plugin while its contents are evaluated. That way you could ensure that the translations are taken from your plugin instead of the core…