6
votes

I'm looking for a way to translate my Django project. Built in mechanism provided with Django is great, but has several weak points which made me go looking for an alternative.

Project owner must be able to edit every translation including English (original translation). With gettext it is possible to edit translations with tools like Pootle, but the original strings stay hardcoded inside file sources or templates. There is no way that product owner can change them.

Possible solution is to make gettext translate some unique identifiers, and just translate them to all languages including English, like this:

_('form_sumbit_button')

But this makes tools like pootle almost impossible to use for translators.

Question: are there any tools for Django project translation that could fit my needs?

3

3 Answers

3
votes

If you use some message IDs, they would either be incomprehensible ("message_2215") or you'd be forced to synchronise the message IDs to the actual messages ("Please press any key" = "please_press_any_key" => "Any key to continue" = "any_key_to_continue"). Either way, real strings are better for the programmers and for the tools.

However, if you employ a separate proof-reader for your strings, you can do the following:

  1. Create an English "translation" file (yes, this works)
  2. Let your proof-reader "translate" from English to English using Pootle or any other tool
  3. Make sure your programmers keep that translation file untranslated by updating the strings in code.
  4. (optional) Create a way to deploy translations independently of your main code so you can fix a typo quickly.
1
votes

You may be able to use Pootle with the _("message_id") approach, depending on how easy Pootle is to customise (I don't know the internals so I can't say, but IIUC it uses Django where template changes are usually straightforward).

For example, Pootle's translation screens have "Original" and "Translation" sections; you could perhaps adapt the templates to show, under the "Original" section, a "Reference" section which displays some canonical translation using a specific reference language (e.g. English).

Or you may be able to use Pootle's alternative source language functionality, without needing to customise Pootle. You could store the canonical versions of the translations using an unused language code (or a made-up one).

0
votes

Using identifiers is definitely possible with Gettext and there are tools which support this. However it might be unusual for some translators as they are used to downloading only .po file for offline translation, what does not work with monolingual translations.

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