[−][src]Macro gettext_macros::t
t!() { /* proc-macro */ }
Marks a string as translatable
It only adds the given string to the .pot
file, without translating it at runtime.
To translate it for real, you will have to use i18n
. The advantage of this macro, is
that you mark a string as translatable without requiring a catalog to be available in scope.
Return value
In case of a singular message, the message itself is returned.
For messages with a plural form, it is a tuple containing the singular form, and the plural one.
Example
ⓘThis example is not tested
#use gettext_macros::*; // Let's say we can't have access to a Catalog at this point of the program let msg = t!("Hello, world!"); let plural = t!("Singular", "Plural") // Now, let's get a catalog, and translate these messages let cat = get_catalog(); i18n!(cat, msg); i18n!(cat, plural.0, plural.1; 57);
Syntax
This macro accepts the following syntaxes:
ⓘThis example is not tested
t!($singular) t!($singular, $plural) t!(context = $ctx, $singular) t!(context = $ctx, $singular, $plural)
Where $singular
, $plural
and $ctx
all are str
literals (and not variables, expressions or literal of any other type).