Skip to content

Translating Lernanta

zuzelvp edited this page Apr 21, 2011 · 50 revisions

Under Construction

Using lernanta in your preferred language

Although you can use the links at the upper right side to show one page in other supported language, to automatically switch the whole interface to your preferred language, please configure your browser so it redirects you to http://new.p2pu.org/[locale_name]/[path]. With Firefox from Edit-> Preferences -> Content -> Language, add your preferred language (e.g Spanish) and put it at the top of the list. Soon we will provide a way to configure this inside the user settings in Lernanta so you will see the site in your preferred language after you login.

Improving an existing localization

For helping us to translate Lernanta into other languages, please suggest corrections to the files at the locale directory. You can create tickets at lighthouse an tag them as internationalization localization.

Starting a new localization

Lernanta prefers localizations of generic languages (e.g en, us), instead of languages specific to a country (e.g en-US, es-CO). Now that we are starting it will be easier to join efforts between people from different countries. However, there is no roadblock from the technological part impeding the creation of specific translations, and we will probably do so as the community of translators grows.

The easiest way to translate Lernanta into another language is to download an existing django.po file, change the translations to your language and attach the file to a new ticket at lighthouse (this is an example).

If you prefer to fork the git repository and work on it have in mind:

  • You need to install gettext to be able to generate, update and compile the django.po files (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 manage.py 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 error that there could be

    $ python manage.py compilemessages -l es

  • Update periodically and run again makemessages or easier, run:

    $ ./int.sh

After updating edit 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$ ).

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

    "de":{ "English":"German", "internal":"de", "external":"de", "dictionary":"de", "native":"Deutsch" },

  • 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 text and html templates the translatable strings should be surrounded with {{ _('dear') }}. In general we don't include markup in the translatable string (see exception below).

  • The splash string is special since it could require adjusting design elements in order to be presented correctly in your language. You can do it by: (1) creating a style file, for example media/css/stil.css that override style elements (see for example media/css/estilo.css), (2) reference that file with the translation of the translatable string css/style-lang.css in your django.po file and (3) adjusting line breaks and markup in the translated string corresponding to the splash screen in your file locale/de/LC_MESSAGES/django.po

  • Django provides documentation about internationalization and localization

Clone this wiki locally