

When extracted from source, translations are placed into. Gettext is able to automatically extract translations from your source code, alleviating developers and translators from the repetitive and error-prone work of maintaining translation files. Read the documentation for the Gettext module for more information on locales, interpolation, pluralization, and other features. Some may even use existing tools for managing them, such as Poedit or .įinally, because translations are based on strings, your source code does not lose readability as you still see literal strings, like gettext("here is an example"), instead of paths like translate(""). po are text-based files and can be edited directly by translators. Msgstr "Aqui estão os textos para traduzir" Msgid_plural "Here are the strings to translate" Msgstr "Aqui está um texto para traduzir"

Such files must be placed at priv/gettext/LOCALE/LC_MESSAGES/DOMAIN.po, where LOCALE is the locale and DOMAIN is the domain (the default domain is called default).įor example, the translation to pt_BR of the first two *gettext calls in the snippet above must be placed in the priv/gettext/pt_BR/LC_MESSAGES/default.po file with contents: msgid "Here is one string to translate" Translations in Gettext are stored in Portable Object files (. Ngettext("The apple is ripe", "The apples are ripe", number_of_apples)ĭgettext("errors", "Here is an error message to translate") Gettext("Here is one string to translate") To use Gettext, define a Gettext module: defmodule MyApp.Gettext doĪnd invoke the Gettext API, which consists of the *gettext macros: import MyApp.Gettext po files change: def project doĭocumentation for Gettext is available on Hex. Optionally add the :gettext compiler to your Mix compilers so your backends are recompiled when. InstallationĪdd :gettext to your list of dependencies in mix.exs (use $ mix hex.info gettext to find the latest version): def deps do This project is an implementation of the Gettext system in Elixir. Gettext is a standard for i18n in different communities, meaning there is a great set of tooling for developers and translators. Gettext is an internationalization (i18n) and localization (l10n) system commonly used for writing multilingual programs.
