Copyright © (C) 2014, Sergey Prokhorov; 2014, Emil Falk
Authors: Sergey Prokhorov (me@seriyps.ru), Emil Falk (emil.falk@textalk.se).
The gettexter API exports functions similar to those offered by GNU gettext. All lookup function works with both binaries and strings but not mixed. The locale may be either atom, binary or string.
Several macros can be found in include/shortcuts.hrl
. They are provided as
a convienient way to mark up your strings or binaries and to simplify
extraction via xgettext. All possible combinations from the API is provided.
To set a default domain for the macros with implicit domain below use the
constant GETTEXT_DOMAIN as for example:
-define(GETTEXT_DOMAIN, users).
locale() = atom() | binary() | string()
text() = binary() | string()
bind_textdomain_codeset/2 | TODO. |
bindtextdomain/2 | Bind a domain to a directory. |
dgettext/2 | Translate a domain-specific text. |
dgettext/3 | Translate a domain-specific text given a locale. |
dngettext/4 | Translate a domain-specific plural text. |
dngettext/5 | Translate a domain-specific plural text given a locale. |
dnpgettext/5 | Translate a domain-specific plural text in a context. |
dnpgettext/6 | Translate a domain-specific plural text in a context given a locale. |
dpgettext/3 | Translate a domain-specific text in a context. |
dpgettext/4 | Translate a domain-specific text in a context given a locale. |
ensure_loaded/3 | Ensure that Locale is loaded. |
getlocale/1 | Get the locale from the process dictionary. |
gettext/1 | Translate text. |
gettext/2 | Translate text to a given locale. |
ngettext/3 | Translate plural text. |
ngettext/4 | Translate plural text given a locale. |
npgettext/4 | Translate a plural text in a context. |
npgettext/5 | Translate a plural text in a context given a locale. |
pgettext/2 | Translate a text in a context. |
pgettext/3 | Translate a text in a context given a locale. |
reload/1 | Reload locales from previously bound textdomain Note: only new and existing keys are added/updated; keys that were removed from .mo file are not going to be removed from database! |
reload/2 | |
reset/0 | Reset the process dictionary Remove all gettext stuff from process dictionary (but not from locale data storage). |
setlocale/2 | Set the locale in the process dictionary. |
textdomain/0 | Get the text domain. |
textdomain/1 | Set the text domain. |
which_domains/0 | which unique domains are loaded. |
which_domains/1 | Which domains are loaded for Locale . |
which_locales/1 | Which locales are loaded for Domain . |
bind_textdomain_codeset(Domain::atom(), Charset::string()) -> ok
TODO
bindtextdomain(Domain::atom(), Localedir::file:filename()) -> ok
Bind a domain to a directory. Bind a given domain to a directory where the compiled translated .mo-files are located. Should be called att configuration time, otherwise the default directory priv/locale/ will be used.
Translate a domain-specific text.
Translate a domain-specific text given a locale.
Translate a domain-specific plural text.
dngettext(Domain::atom(), Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type
Translate a domain-specific plural text given a locale.
dnpgettext(Domain::atom(), Context::Type | undefined, Singular::Type, Plural::Type, N::integer()) -> Type
Translate a domain-specific plural text in a context.
dnpgettext(Domain::atom(), Context::Type | undefined, Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type
Translate a domain-specific plural text in a context given a locale.
Translate a domain-specific text in a context.
dpgettext(Domain::atom(), Context::Type | undefined, Text::Type, Locale::locale()) -> Type
Translate a domain-specific text in a context given a locale.
ensure_loaded(Domain::atom(), Category::lc_messages, Locale::locale()) -> {ok, file:filename() | already} | {error, any()}
Ensure that Locale
is loaded.
If the locale isn't loaded, all lookups will return their own inputs.
getlocale(Category::lc_messages) -> locale() | undefined
Get the locale from the process dictionary.
Translate text. Locale in process dictionary.
Translate text to a given locale
Translate plural text.
Translate plural text given a locale.
npgettext(Context::Type | undefined, Singular::Type, Plural::Type, N::integer()) -> Type
Translate a plural text in a context.
npgettext(Context::Type | undefined, Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type
Translate a plural text in a context given a locale.
Translate a text in a context.
Translate a text in a context given a locale.
reload(Domain) -> any()
Reload locales from previously bound textdomain Note: only new and existing keys are added/updated; keys that were removed from .mo file are not going to be removed from database!
reload(Domain::atom(), Locales::[locale()]) -> [{locale(), ok, file:filename()} | {locale(), error, any()}]
reset() -> ok
Reset the process dictionary Remove all gettext stuff from process dictionary (but not from locale data storage).
setlocale(Category::lc_messages, Locale::locale()) -> ok
Set the locale in the process dictionary.
textdomain() -> atom() | undefined
Get the text domain.
textdomain(Domain::atom()) -> ok
Set the text domain.
which_domains() -> [atom()]
which unique domains are loaded.
which_domains(Locale::locale()) -> [atom()]
Which domains are loaded for Locale
.
which_locales(Domain::atom()) -> [locale()]
Which locales are loaded for Domain
.
Generated by EDoc