-
Notifications
You must be signed in to change notification settings - Fork 192
Internationalization
| « back to DeveloperGuide |
|---|
Person Finder follows the Django convention for "language code" versus "locale code". A language code is a lowercase ISO 639-1 language code, optionally followed by a hyphen and an uppercase ISO 3166-1 two-letter country code. A locale code is like a language code except that it uses an underscore instead of a hyphen. The use of locale and lang for variable and function names in Person Finder should follow this convention.
Setting the lang query parameter to a language code sets the display language (on any page). The language code is also saved in a browser cookie, which determines the language when there is no lang parameter.
Localized messages are stored in app/locale in a directory named after the locale code, in .po format. For example, French messages are in app/locale/fr/LC_MESSAGES/django.po. These .po files are compiled into .mo files, which are used at runtime.
Whenever you change strings in the code, you should run tools/update_messages, which will scan the Python code and all the Django templates for strings, update the .po files with new strings, compile them into the appropriate .mo files, and then print a report listing the messages that have missing translations in each language. In general, you will rarely need to run tools/update_messages directly, because running the tests with tools/server_tests automatically runs tools/update_messages.
Take the following steps to add a new language:
- Important: stop any local running appservers
- Run
tools/update_messages - Create a new directory for the language at
app/locale/locale_code/LC_MESSAGES - Copy
app/locale/en/LC_MESSAGES/django.pointo your new directory
- Edit this new
django.pofile to add the translated messages for the new language
- Run
tools/update_messagesagain to compile and convert the new translated messages
- Add the new language to
LANGUAGE_ENDONYMSandLANGUAGE_EXONYMSinapp/utils.py - Add the new language to the
lang-testsubdomain intools/setup.py - Run the tests as explained in HowToDevelop
- Run
dev_appserver.py appand then go tohttp://localhost:8080/?subdomain=lang-testto try out the new language
- If everything looks good, run
hg addto add your new message files, commit, and request a code review
| « back to DeveloperGuide |
|---|