A package to provide type safe internationalisation, where translations can be loaded at runtime. Default translations, substitutions and pluralization are supported.
Substitutions are implemented by surrounding the literal in braces:
"MyNameIs": "Je m'appelle {name}"Pluralization is implemented by having the singular case on the left of the pipe symbol, and all
other cases on the right. The number can be substituted using {count}.
"MyAge": "I am only one year old|I'm {count} years old"See the example/ directory for an example of the package being used.
This creates a Translator with the given default Translations, but no loaded Translations. Typically this would be used when initializing your program's Model to make sure there are some translations on startup.
Update an existing Translator with the given loaded Translations. Typically this would be used to update an existing Translator when you have loaded some Translations at runtime.
Get the translations out of the Translator (if there are any).
This creates a Json Decoder that will decode Json of the form:
{
"Yes": "Oui",
"No": "Non"
}into a valid Translator that can be used with the translation functions in this package. You need to provide a Translations parameter which contains the default translations, in case a translation can't be matched.
Given an id and a Translator, translate to a String. This can never fail, and in the event of being unable to match in either the loaded or default literals this will fall back to "...". This supports substitutions and pluralization.
Substitutions and pluralization are supported (see the top-level package doumentation).
A translated version of Html.text for use directly in an Elm view
A translated version of Html.Attributes.placeholder for use directly in an Elm view
A Translator contains all the required information to translate strings into other languages.