Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django i18n: is there a gettext alternative?

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?

like image 832
Silver Light Avatar asked Dec 29 '10 14:12

Silver Light


2 Answers

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.
like image 52
Nikolai Prokoschenko Avatar answered Oct 14 '22 01:10

Nikolai Prokoschenko


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).

like image 37
Vinay Sajip Avatar answered Oct 14 '22 01:10

Vinay Sajip