Translating Lernanta

Dirk Uys edited this page May 10, 2013 · 50 revisions

This page describes what to do in order to translate or how to improve existing translations. You are welcome to join p2pu-dev mailing list for any questions.

Improving an existing translation

Existing translation can be seen here. The folder names correspond to the language code. To update the translation, you can download the .po file. For example, if you would like to update the Spanish translation, you would download this file and then edit it.

Starting a new localization

To start a new translation you can download an existing translation file and update it.

To join efforts between people from different countries we translate to generic languages (e.g en, us), instead of country specific versions of a languages (e.g en-US, es-CO) because it's easier . However, there is nothing stopping you from translating to a country specific dialect of a language.

Submitting your changes

Once you are finished updating the translation, give us a shout on the p2pu-dev mailing list. Alternatively, you can also use github and submit a pull request with the changes you made.

Editing a .po file

The translation file (LC_MESSAGES/django.po) is a normal text file that you can edit with any text editor. There are also several tools that makes it easier to update the file. Depending on your platform you may choose to use a different tool, just search for 'how to edit a .po file'.

Special Translation Strings

Some of the strings that need to be translated have special purposes (e.g., to allow the internationalization of third party tools, the customization of styles, or to define date formats). See examples of how to translate them in the django.po files of another language.

msgid "en"
msgid "js/script-en.js"
msgid "css/style-en.css"
msgid "jquery.ui.datepicker-en.js"

For the brave

It is also possible to download the lernanta source code and use django to generate new translation files. Here are a few hints:

  • You need to install gettext to be able to generate, update and compile the django.po files (with Ubuntu you can use sudo apt-get install gettext in Ubuntu).
  • To extract the translatable strings for a particular locale name, which needs to be one of the locale names supported by Django (replace de (german) with the locale for your language in all the examples provided below):
$ python makemessages -e ".html,.txt,.py" -l de
  • Then start translating the strings at locale/de/LC_MESSAGES/django.po We recommend you see how other widely used website (e.g., wikipedia, twitter, gmail, yahoo, facebook, wordpress, ...) have translated some terms.
  • Compile your messages and correct any errors.
$ python compilemessages -l de
  • Update periodically and run again makemessages or easier, run:
$ sh/int

After updating your django.po file and look for strings that require better translation by searching the word fuzzy, or strings that require a new translations by searching for msgstr "" followed by two new lines (with vim use in command mode /msgstr ""\n\n ). You can also cleanup translations that are not used anymore which will appear commented at the end of the file.

  • To be able to see the translations in the browser add the locale at apps/l10n/languages.json (in case it is not there yet):


Lets see a few more details that could be needed to improve the results.

  • In the python code of Lernanta a string (e.g 'dear') should be surrounded with the function _() (i.e _('dear') ) in order to make it translatable. In the plain text and html templates the translatable strings should be surrounded with {{ _('dear') }}. In general we don't include markup in the translatable string (unless it allows more freedom when translating sentences which contain links). If you find a string in the code which is not marked for translation please let us know.
  • Sometimes the translations will be long or disrupt the site appearance (e.g. in the site homepage or the main menu). In those cases you could adjust design elements (or report the problem so we can help) inside media/css/style-[your locale].css (this file will need to be created for new languages).
  • Lernanta uses a few external tools that should appear translated as well: JQuery DatePicker, CKEditor, and ReCaptcha. Fortunately these tools are already translated to several languages so we can help configuring this part.

See Also

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.