kielet/language
A language contains translations and plural form information, and can be used to translate messages.
Types
Error returned when an MO file is loaded.
pub type LanguageLoadError {
MoParseError(err: mo.ParseError)
PluralFormsLoadError(err: plurals.LoadError)
}
Constructors
-
MoParseError(err: mo.ParseError)
The MO file could not be parsed.
-
PluralFormsLoadError(err: plurals.LoadError)
The plural forms in the MO file were invalid or missing.
Error when trying to translate a message.
pub type TranslateError {
MsgIsSingular(String)
MsgIsPlural(String)
MsgNotFound(String)
PluralOutOfBounds(requested: Int, but_max_is: Int)
}
Constructors
-
MsgIsSingular(String)
Tried to translate a plural message, but the translation is singular.
-
MsgIsPlural(String)
Tried to translate a singular message, but the translation is plural.
-
MsgNotFound(String)
There was no translation for the message.
-
PluralOutOfBounds(requested: Int, but_max_is: Int)
The plural algorithm returned a form that is out of bounds for the amount of plural forms.
Functions
pub fn get_plural_translation(
lang: Language,
msgid: String,
n: Int,
) -> Result(String, TranslateError)
Translate a plural message.
pub fn get_singular_translation(
lang: Language,
msgid: String,
) -> Result(String, TranslateError)
Translate a singular message.