Internationalization
Terms defined: Internationalization (i18n), Localization (l10n)
- Internationalization (often abbreviated "i18n" because of the number of letters) is the preparation of software for multilingual support
- Localization (often abbreviated "l10n") is the process of making internationalized software accessible to people using various languages and symbologies
- A lot of software is built on top of gettext
- We will build our own to show how it works
test_translation.py
:- Register a function with Jinja2 so that we can call it inside our template
- Define a translation table
- Use an object that creates a translation function that captures the language
- Call the translation function
_()
to save typing
util.py
loads a translation table based on (yet another) environment variableviews.py
uses the request'saccept_languages
property to look up the user's desired language codeserver.py
passesrequest.accept_languages
to view functionsrequest_lang.py
gets a resource with an explicitAccept-Language
header- Can/should use unit tests from Testing the Server and Testing in the Browser