An Elm package for internationalization (i18n) using GNU gettext MO/PO files. This library allows you to load compiled binary translation files (.mo) and translate text at runtime in your Elm application.
t, tn, tp, tpn API for translation functions{placeholder} syntaxAdd this package to your Elm project:
elm install panthus/elm-gettextA typical i18n workflow looks like this:
Write your Elm code using t, tn, tp, tpn functions for all translatable strings
Note that translatable strings cannot be dynamically passed to the translation functions (via variables, loaded from somewhere etc), because the extraction tool requires static strings to be able to extract them into a .pot file.
Extract strings from your code into a .pot template file using @panthus/elm-xgettext
Create/update .po files from the .pot file for each target language
Translate the strings in each .po file (using POEdit or similar)
Compile .po files to .mo binary files using @panthus/elm-xgettext
Load the .mo files at runtime in your application
See the example/ directory for a complete working example demonstrating:
t, tn, tp, tpn)