Framework.I18n.Gettext (Framework v0.5.0)
View SourceGettext backend for Framework internationalization.
This module uses Gettext to provide compile-time translations for framework messages and errors. Product applications can use this backend or define their own.
Translation Files
Translation files are stored in priv/gettext/<locale>/LC_MESSAGES/:
priv/gettext/
en-US/LC_MESSAGES/
default.po # Default domain for general messages
errors.po # Error messages
es-ES/LC_MESSAGES/
default.po
errors.po
fr-FR/LC_MESSAGES/
default.po
errors.poExtracting Translations
Use the built-in Gettext tasks to extract and merge translations:
# Extract translation keys from code
mix gettext.extract
# Merge new keys into existing .po files
mix gettext.merge priv/gettextAdding New Translations
- Add translation calls in code using
Framework.I18n.t/3 - Run
mix gettext.extractto extract keys - Run
mix gettext.merge priv/gettextto update .po files - Edit .po files to add translations
Summary
Functions
Callback implementation for Gettext.Backend.handle_missing_bindings/2.
Callback implementation for Gettext.Backend.handle_missing_plural_translation/7.
Callback implementation for Gettext.Backend.handle_missing_translation/5.
Returns the path to the Gettext locales directory.
Functions
Callback implementation for Gettext.Backend.handle_missing_bindings/2.
Callback implementation for Gettext.Backend.handle_missing_plural_translation/7.
Callback implementation for Gettext.Backend.handle_missing_translation/5.
Returns the path to the Gettext locales directory.
This is used by Gettext to find translation files.