1

Our company generates reports that often use a dual language format. For instance:

English Test Name / Chinese Test Name: Result cm

We have our translations already set and I have generated .po/.mo files and can do a single language without problem. However, is there a way, with builtin Django functionality, to do the dual language option. The current format for a template,

{% trans "Key" %}

leaves a little to be desired with what we are doing. Maybe

{% blocktrans %}

would be better?

My wanting to just throw logic at it wonders if there is a way to use

{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}

to get at the selected language and then manipulate the language that way somehow.

Any ideas beyond re-writing the Middleware?

geraldcor
  • 209
  • 3
  • 13

1 Answers1

0

I'm not aware of how to do it inside of a template, but the i18n python framework has the ability to activate a language using django.utils.translation.activate to activate a given language. A brief glance at the templatetags code for trans and blocktrans it appears there isn't anything like this implemented for the template tags, however you could write your own tags that wrap trans and blocktrans and allow you to specify a certain language as an argument.

Donald Stufft
  • 1,148
  • 8
  • 11
  • I believe this may be the only way to go. I will update on my progress. Thanks. – geraldcor Jul 05 '11 at 17:06
  • This probably wouldn't be a terrible thing to add as a patch to the built in trans and blocktrans tags if you feel up to submitting a patch to Django. – Donald Stufft Jul 05 '11 at 19:00
  • http://stackoverflow.com/questions/3176213/django-how-to-force-translation-into-a-given-language-inside-a-template – maazza Jun 05 '13 at 19:30