Next: GNU Smalltalk, Previous: Modula-2, Up: Individual Programming Languages [Contents][Index]
gcc-gdc or ldc
gdc or ldc
d
r"abc", `abc`, "abc",
q"[abc]", q"(abc)", q"<abc>", q"{abc}",
q{abc}, x"6A 6B 6C"
_("abc")
gettext, dgettext, dcgettext,
ngettext, dngettext, dcngettext
Note that the ngettext-like functions need to take
two argument strings that consume the same number of arguments.
For example, you cannot write
format(ngettext("a piece", "%d pieces", n), n)
because in the singular case,
format would treat the unused argument as an error and
throw an exception.
As a workaround, you need to convert n to a string and
format that string with precision zero:
format(ngettext("%.0sa piece", "%s pieces", n), to!string(n))
or
format(ngettext("%.0sa piece", "%s pieces", n), text(n))
textdomain function
bindtextdomain function
Programmer must call setlocale (LC_ALL, "")
import gnu.libintl;
alias _ = gettext;
Use
xgettext -k_ --flag=_:1:pass-c-format --flag=_:1:pass-d-format
fprintf "%2$d %1$d", format "%2$d %1$d"
fully portable
—
An example is available in the examples directory: hello-d.