gettext

Internationalization compatible with GNU gettext.

Members

Aliases

Key
alias Key = Tuple!(string, "singular", string, "plural", Format, "format", string, "context")
Undocumented in source.

Enums

Format
enum Format
Undocumented in source.
Tr
enum Tr

Optional attribute categories.

Functions

availableLanguages
string[] availableLanguages(string moPath)

Collect a list of available *.mo files.

languageCode
string languageCode()

Returns the language code for the current language.

languageCode
string languageCode(string moFile)

Returns the language code for the translation contained in moFile.

messageFromKey
string messageFromKey(Key key)
Undocumented in source. Be warned that the author may not have intended to support it.
scan
bool scan()
Undocumented in source. Be warned that the author may not have intended to support it.
selectLanguage
void selectLanguage(string moFile)

Switch to the language contained in moFile.

stringify
string stringify(string str)
Undocumented in source. Be warned that the author may not have intended to support it.
tr
string tr()

Translate message.

tr
string tr(size_t n)

Translate a message in the correct plural form.

Manifest constants

main
enum main;

Code to be mixed in at the top of your main() function.

Structs

TranslatableString
struct TranslatableString
Undocumented in source.
TranslatableStringPlural
struct TranslatableStringPlural
Undocumented in source.

Templates

tr
template tr(string singular, string[Tr] attributes = null, int line = __LINE__, string file = __FILE__, string mod = __MODULE__, string func = __FUNCTION__, Args...)
Undocumented in source.
tr
template tr(string singular, string plural, string[Tr] attributes = null, int line = __LINE__, string file = __FILE__, string mod = __MODULE__, string func = __FUNCTION__, Args...)
Undocumented in source.
tr
template tr(string singular, string[Tr] attributes = null)
Undocumented in source.
tr
template tr(string singular, string plural, string[Tr] attributes = null)
Undocumented in source.

Variables

potFile
string potFile;
Undocumented in source.

See Also

GNU gettext utilities

Translatable strings are marked by instantiating the tr template, like so:

writeln(tr!"Translatable message");

If you'd rather use an underscore to mark translatable strings, [as the GNU gettext documentation suggests](https://www.gnu.org/software/gettext/manual/html_node/Mark-Keywords.html), you can use an alias:

import gettext : _ = tr;    // Customary in GNU software.
writeln(_!"Translatable message");

Meta