Django i18n: is there an alternative to gettext?

I am looking for a way to translate my Django project. The built-in mechanism provided by Django is wonderful, but it has several weaknesses that made me look for an alternative.

The project owner should be able to edit each translation, including English (original translation). Using gettext, you can edit translations using tools such as Pootle , but the source strings remain hardcoded inside file or template sources. The product owner cannot change them.

A possible solution is to get gettext to translate some unique identifiers and just translate them into all languages, including English, for example:

_('form_sumbit_button') 

But that makes tools like the pootle almost impossible for translators.

Question: Are there any translation tools for the Django project that can fit my needs?

+6
python django internationalization gettext pootle
source share
4 answers

If you use some message identifiers, they will either be incomprehensible ("message_2215"), or you will have to synchronize the message identifiers with the actual messages ("Please press any key" = "please_press_any_key" => "Any key to continue" = "any_key_to_continue" ) In any case, real lines are better for programmers and for tools.

However, if you use a separate corrector for your lines, you can do the following:

  • Create an English "translation" (yes, it works)
  • Let your corrector "translate" from English into English using Pootle or any other tool.
  • Make sure your programmers do not transfer this translation file by updating lines in the code.
  • (optional) Create a way to deploy translations, regardless of your main code, to quickly fix a typo.
+2
source share

You can use Pootle with the _ ("message_id") approach, depending on how easy it is to configure Pootle (I don’t know the internal elements, so I can’t say, but IIUC uses Django, where the change pattern is usually simple).

For example, Pootle translation screens have sections "Original" and "Translation"; you could possibly adapt the templates to show the "Link" section in the "Original" section, which displays some canonical translation using a specific reference language (for example, in English).

Or you can use the Pootle functionality with an alternative source language , without having to configure Pootle. You can save canonical versions of translations using an unused language code (or one created).

+1
source share

I had the same problem and did not base any third-party solution, so I wrote this library: https://github.com/fabiocaccamo/django-kway

Hope someone finds this helpful.

0
source share

Using identifiers is certainly possible with Gettext, and there are tools that support this. However, for some translators this may be unusual since they are used to download only the .po file for offline translation, which does not work with monolingual translations.

For example Weblate supports monolingual Gettext files just fine (I'm the author of this tool): https://docs.weblate.org/en/latest/formats.html#monolingual-gettext

0
source share

All Articles