-
Notifications
You must be signed in to change notification settings - Fork 64
Translating Lernanta
The following sections try to describe what to do in order to translate new.p2pu.org into different languages. You are welcome to join p2pu-dev mailing list for more help.
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.
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.
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 errors.
$ python manage.py compilemessages -l de
- 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$
). 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):
"de":{
"English":"German",
"internal":"de",
"external":"de",
"dictionary":"de",
"native":"Deutsch"
},
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.
- Documentation provided by Django about internationalization and localization.