Module gettexter

gettexter

.

Copyright © (C) 2014, Sergey Prokhorov; 2014, Emil Falk

Authors: Sergey Prokhorov (me@seriyps.ru), Emil Falk (emil.falk@textalk.se).

Description

gettexter

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.

Macros

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 in process dictionary

Domain from GETTEXT_DOMAIN
Domain as argument

Locale as argument

Domain from GETTEXT_DOMAIN
Domain as argument

Data Types

locale()

locale() = atom() | binary() | string()

text()

text() = binary() | string()

Function Index

bind_textdomain_codeset/2TODO.
bindtextdomain/2Bind a domain to a directory.
dgettext/2Translate a domain-specific text.
dgettext/3Translate a domain-specific text given a locale.
dngettext/4Translate a domain-specific plural text.
dngettext/5Translate a domain-specific plural text given a locale.
dnpgettext/5Translate a domain-specific plural text in a context.
dnpgettext/6Translate a domain-specific plural text in a context given a locale.
dpgettext/3Translate a domain-specific text in a context.
dpgettext/4Translate a domain-specific text in a context given a locale.
ensure_loaded/3Ensure that Locale is loaded.
getlocale/1Get the locale from the process dictionary.
gettext/1Translate text.
gettext/2Translate text to a given locale.
ngettext/3Translate plural text.
ngettext/4Translate plural text given a locale.
npgettext/4Translate a plural text in a context.
npgettext/5Translate a plural text in a context given a locale.
pgettext/2Translate a text in a context.
pgettext/3Translate a text in a context given a locale.
reload/1Reload 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/0Reset the process dictionary Remove all gettext stuff from process dictionary (but not from locale data storage).
setlocale/2Set the locale in the process dictionary.
textdomain/0Get the text domain.
textdomain/1Set the text domain.
which_domains/0which unique domains are loaded.
which_domains/1Which domains are loaded for Locale.
which_locales/1Which locales are loaded for Domain.

Function Details

bind_textdomain_codeset/2

bind_textdomain_codeset(Domain::atom(), Charset::string()) -> ok

TODO

bindtextdomain/2

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.

dgettext/2

dgettext(Domain::atom(), Text::Type) -> Type

Translate a domain-specific text.

dgettext/3

dgettext(Domain::atom(), Text::Type, Locale::locale()) -> Type

Translate a domain-specific text given a locale.

dngettext/4

dngettext(Domain::atom(), Singular::Type, Plural::Type, N::integer()) -> Type

Translate a domain-specific plural text.

dngettext/5

dngettext(Domain::atom(), Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type

Translate a domain-specific plural text given a locale.

dnpgettext/5

dnpgettext(Domain::atom(), Context::Type | undefined, Singular::Type, Plural::Type, N::integer()) -> Type

Translate a domain-specific plural text in a context.

dnpgettext/6

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.

dpgettext/3

dpgettext(Domain::atom(), Context::Type | undefined, Text::Type) -> Type

Translate a domain-specific text in a context.

dpgettext/4

dpgettext(Domain::atom(), Context::Type | undefined, Text::Type, Locale::locale()) -> Type

Translate a domain-specific text in a context given a locale.

ensure_loaded/3

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/1

getlocale(Category::lc_messages) -> locale() | undefined

Get the locale from the process dictionary.

gettext/1

gettext(Text::Type) -> Type

Translate text. Locale in process dictionary.

gettext/2

gettext(Text::Type, Locale::locale()) -> Type

Translate text to a given locale

ngettext/3

ngettext(Singular::Type, Plural::Type, N::integer()) -> Type

Translate plural text.

ngettext/4

ngettext(Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type

Translate plural text given a locale.

npgettext/4

npgettext(Context::Type | undefined, Singular::Type, Plural::Type, N::integer()) -> Type

Translate a plural text in a context.

npgettext/5

npgettext(Context::Type | undefined, Singular::Type, Plural::Type, N::integer(), Locale::locale()) -> Type

Translate a plural text in a context given a locale.

pgettext/2

pgettext(Context::Type | undefined, Text::Type) -> Type

Translate a text in a context.

pgettext/3

pgettext(Context::Type | undefined, Text::Type, Locale::locale()) -> Type

Translate a text in a context given a locale.

reload/1

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/2

reload(Domain::atom(), Locales::[locale()]) -> [{locale(), ok, file:filename()} | {locale(), error, any()}]

reset/0

reset() -> ok

Reset the process dictionary Remove all gettext stuff from process dictionary (but not from locale data storage).

setlocale/2

setlocale(Category::lc_messages, Locale::locale()) -> ok

Set the locale in the process dictionary.

textdomain/0

textdomain() -> atom() | undefined

Get the text domain.

textdomain/1

textdomain(Domain::atom()) -> ok

Set the text domain.

which_domains/0

which_domains() -> [atom()]

which unique domains are loaded.

which_domains/1

which_domains(Locale::locale()) -> [atom()]

Which domains are loaded for Locale.

which_locales/1

which_locales(Domain::atom()) -> [locale()]

Which locales are loaded for Domain.


Generated by EDoc