z_trans (zotonic_core v1.0.0-rc.12)

Translate english sentences into other languages, following the GNU gettext principle.

Link to this section Summary

Functions

Strict translation lookup of a language version
Non strict translation lookup of a language version. In order check: requested language, default configured language, english, any
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
Fetch all translations for the given string.

Link to this section Functions

Link to this function

lookup(Trans, Context)

-spec lookup(z:trans() | binary() | string(), #context{}) -> binary() | string() | undefined.
Strict translation lookup of a language version
Link to this function

lookup(Trans, Lang, Context)

-spec lookup(z:trans() | binary() | string(), atom(), #context{}) -> binary() | string() | undefined.
Link to this function

lookup_fallback(Trans, Context)

-spec lookup_fallback(z:trans() | binary() | string() | undefined, z:context() | undefined) ->
                   binary() | string() | undefined.
Non strict translation lookup of a language version. In order check: requested language, default configured language, english, any
Link to this function

lookup_fallback(Trans, Lang, Context)

Link to this function

lookup_fallback_language(Langs, Context)

-spec lookup_fallback_language([atom()], z:context()) -> atom().
Link to this function

lookup_fallback_language(Langs, Lang, Context)

-spec lookup_fallback_language([atom()], atom(), z:context()) -> atom().
Link to this function

parse_translations(Context)

-spec parse_translations(z:context()) -> map().
Prepare a translations table based on all .po files in the active modules. Returns a map of english sentences with all their translations
Link to this function

trans(Trans, Lang)

-spec trans(z:trans() | binary() | string(), z:context() | atom()) -> binary() | undefined.
translate a string or trans record into another language
Link to this function

trans(Trans, Language, Context)

Link to this function

translations(Trans, Context)

-spec translations(z:trans() | binary() | string(), z:context()) -> z:trans() | binary().
Fetch all translations for the given string.