TranslatableString

Represents a translatable string.

This struct can for the most part be considered an implementation detail of gettext. A template instantiation like tr!"Greetings" actually results in a constructor call like TranslatableString("Greetings") in the code. This struct is callable, so that a lookup of the translation happens when the struct is evaluated.

The only reason that this struct is public is to make declarations of static arrays of translatable strings less cryptic:

enum RGB {red, green, blue}

// Explicit array of translatable strings:
immutable TranslatableString[Color.max + 1] colors1 = [RGB.red:   tr!"Red",
                                                       RGB.green: tr!"Green",
                                                       RGB.blue:  tr!"Blue"];
// Array of translatable strings where the type is derived:
immutable typeof(tr!"Red")[Color.max + 1] colors2 = [RGB.red:   tr!"Red",
                                                     RGB.green: tr!"Green",
                                                     RGB.blue:  tr!"Blue"];

Constructors

this
this(string str, string[Tr] attributes)
Undocumented in source.
this
this(string[] seq)
Undocumented in source.
this
this(immutable(string)[] seq)
Undocumented in source.

Alias This

gettext

Members

Functions

gettext
string gettext()
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
TranslatableString opBinary(RHS rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
TranslatableString opBinaryRight(LHS lhs)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

Forces evaluation as translated string.

toString
void toString(void delegate(scope const(char)[]) @(safe) sink)

idem

Meta