-
Notifications
You must be signed in to change notification settings - Fork 0
Languages
So the languages are set up to work if we have the translations. If there are no translations it will just show the English version. Check this for detailed explanation of what I will summarize below:
If you want to translate a string you have in a template, use the template tags: trans or blocktrans. Examples:
- easy
{% load i18n %}
...
{% trans "Explore" %}
{% trans "Your mama" %}
- medium
{% load i18n %}
...
{% blocktrans with course.name as course_name %}
This is the Wiki Page of the course <b>{{course_name}}</b>. ......
{% endblocktrans %}
- hard-core
{% load i18n %}
{% load connect_extras %}
{% url 'resend_confirmation_email' as resend_email_link %}
{% with link_start='<a class="email-confirmation-link" href="#" data-dismiss="alert" src="{0}">'|safewrap:resend_email_link %}
{% blocktrans with "</a>" as link_stop %}
Your account is not yet activated. Please check your email and open the confirmation that we have sent you. {{link_start}} Resend confirmation link {{link_stop}}
{% endblocktrans %}
{% endwith %}
After you wrote the tags, you can get all of the tags with a simple commands:
./manage.py makemessages -l de -e html,txt -i venv -i versioning
./manage.py makemessages -l ro -e html,txt -i venv -i versioning
./manage.py makemessages -l sq -e html,txt -i venv -i versioning
This creates /locale/<language>/LC_MESSAGES/django.po
Give this file to translators
When they are done, use the command:
./manage.py compilemessages
that compiles the .po files to .mo files which will automatically be used when that language is used. How neat!
You will receive a file called django.po which has curious strings like:
#: templates/objects/navbar_login.html:33
msgid "My profile"
msgstr ""
#: templates/objects/navbar_login.html:34
msgid "Manage Account"
msgstr ""
The msgid is what you have to translate and the msgstr is where you have to write the translation in the respective language
(even if it is on separate lines)
Also, please preserve HTML tags or any format you have there. For example
msgid ""
"\n"
" Contribute by %(link_start)s creating %(link_stop)s "
"one.\n"
" "
should translate to:
msgstr ""
"\n"
" Contribuie prin %(link_start)s crearea %(link_stop)s "
"unuia.\n"
" "