-
Notifications
You must be signed in to change notification settings - Fork 6
Adding a Locale to Phaidra (i18n)
- Interface localization (HTML and Javascript Templates, Javascript)
- Content localization (Admin)
- Adding a translated (and aligned) work
Open up phaidra/settings.py. In the section LANGUAGES, add the language:
LANGUAGES = (
('en', 'English'),
('fa', 'Farsi'),
('de', 'German'),
('it', 'Italian'),
('hr', 'Croatian')
)
If you are updating translations, you will need to run the following command so that django finds and appends the new strings to django.po and djangojs.po.
Make sure your virtual environment is activated:
$ source env/bin/activate
And run these commands from the project root (/opt/phaidra). Replace argument of --locale=de with the locale (e.g. fa for Farsi).
$ django-admin.py makemessages --locale=de --extension=html --ignore=env --ignore=*.py
$ django-admin.py makemessages -d djangojs --locale=de --ignore=env --ignore=static/admin/*"
(Developer note: --ignore=static/admin/*
currently does not actually ignore the admin files, owing to a bug in Django. See relevant pull request).
Open /opt/phaidra/locale/*/LC_MESSAGES/django.po
, where * is the locale code you are interested in. You will find sets of strings which look something like this:
# templates/something.html:123
msgid "Words in English"
msgstr "Worte auf Deutsch"
The msgid
is always the original in the file, and the msgstr
is your translation. Simply go through this document and translate the English into your target language.
You repeat the same action as before, but instead edit djangojs.po
.
Once you've translated the strings in django.po and djangojs.po, you need to compile them.
$ django-admin.py compilemessages
This will compile the messages for all languages.
Log in to the Phaidra Admin. You will need to create items within the following App categories:
- Languages
- Content
Simply assign the language you're working on to the Content you create, and it will show up on the interface when the language is selected.
In order to propagate the changes you've made within the admin panel to github, so others can load in your content as well, run the following command.
./manage.py dumpdata --natural --indent=4 --exclude=contenttypes --exclude=auth --exclude=tastypie > app/fixtures/db.json
You can then git add
this file, along with any other localization-related files (e.g. *.mo, *.po), commit them, and push.
- Developer tools and workflow
- API
- Neo4j-powered
- Postgres-powered
- Data
- Internationalization
- General information
- Developer tools and workflow
- Project structure overview
- Frontend vs. Backend Templates
- Backbone.js app structure
- Internationalization for JS
- Guidelines for creating content
- Adding a locale to Phaidra
- Postgres Database
- Neo4j
- Django
- "The server"
- Git
- UI