z_trans (zotonic_core v1.0.0-rc.17)
Translate english sentences into other languages, following the GNU gettext principle.
Summary
Functions
Strict translation lookup of a language version using the languages in the context. If no translation is found or the input is undefined, then undefined is returned.
Strict translation lookup of a language version using the given language or languages. If no translation is found or the input is undefined, then undefined is returned.
Non strict translation lookup of a language version. In order check: requested languages, default configured language, english, any If no translation is found, then the empty binary string is returned.
Non strict translation lookup of a language version. In order check: requested languages, default configured language, english, any If no translation is found, then the empty binary string is returned.
Return the language that would be selected, given the context languages.
Prepare a translations table based on all .po files in the active modules. Returns a map of English sentences with all their translations
translate a string or trans record into another language. Prefer the language translations from the .po files over the translations in the trans record itself.
Fetch all translations for the given English string. If no translations are found then a trans record with the given string is returned.
Functions
-spec lookup(Text, Context) -> Translation when Text :: z:trans() | binary() | string() | undefined, Context :: z:context(), Translation :: binary() | undefined.
Strict translation lookup of a language version using the languages in the context. If no translation is found or the input is undefined, then undefined is returned.
-spec lookup(Text, Language, Context) -> Translation | undefined when Text :: z:trans() | binary() | string() | undefined, Language :: z_language:language_code() | [z_language:language_code()], Context :: z:context(), Translation :: binary().
Strict translation lookup of a language version using the given language or languages. If no translation is found or the input is undefined, then undefined is returned.
-spec lookup_fallback(Text, OptContext) -> Translation when Text :: z:trans() | binary() | string() | list() | undefined, OptContext :: z:context() | undefined, Translation :: binary().
Non strict translation lookup of a language version. In order check: requested languages, default configured language, english, any If no translation is found, then the empty binary string is returned.
-spec lookup_fallback(Text, Language, OptContext) -> Translation when Text :: z:trans() | binary() | string() | list() | undefined, Language :: z_language:language_code() | [z_language:language_code()] | binary(), OptContext :: z:context() | undefined, Translation :: binary().
Non strict translation lookup of a language version. In order check: requested languages, default configured language, english, any If no translation is found, then the empty binary string is returned.
-spec lookup_fallback_languages(Available, Context) -> Language when Available :: [atom()], Context :: z:context(), Language :: atom().
Return the language that would be selected, given the context languages.
Prepare a translations table based on all .po files in the active modules. Returns a map of English sentences with all their translations
-spec trans(Text, ContextOrLanguage) -> Translation when Text :: z:trans() | binary() | string(), ContextOrLanguage :: z:context() | [atom()] | atom(), Translation :: binary().
translate a string or trans record into another language. Prefer the language translations from the .po files over the translations in the trans record itself.
Fetch all translations for the given English string. If no translations are found then a trans record with the given string is returned.