Activating/deactivating locales¶
- django_ftl.activate(locale_code)¶
Activate a locale given by a BCP47 locale code (e.g. “en-US”). All
Bundleobjects will be switched to look for translation files with that locale.This uses a thread local variable internally to store the current locale.
- django_ftl.deactivate()¶
De-activate the currently activated locale. All
Bundleobjects will fallback to the default locale if you try to generate messages with them (or throw exceptions, depending on the value ofrequire_activate), until you activate another language.
- django_ftl.override(locale_code)¶
A Python context manager that uses
activate()to set a locale on entry, and then re-activates the previous locale on exit. It can also be used a function decorator.