File: gettext.info, Node: D, Next: OCaml, Prev: Modula-2, Up: List of Programming Languages
16.5.21 D
---------
RPMs
gcc-gdc or ldc
Ubuntu packages
gdc or ldc
File extension
‘d’
String syntax
‘r"abc"’, ‘`abc`’, ‘"abc"’, ‘q"[abc]"’, ‘q"(abc)"’, ‘q""’,
‘q"{abc}"’, ‘q{abc}’, ‘x"6A 6B 6C"’
gettext shorthand
‘_("abc")’
gettext/ngettext functions
‘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
‘textdomain’ function
bindtextdomain
‘bindtextdomain’ function
setlocale
Programmer must call ‘setlocale (LC_ALL, "")’
Prerequisite
‘import gnu.libintl;’
‘alias _ = gettext;’
Use or emulate GNU gettext
Use
Extractor
‘xgettext -k_ --flag=_:1:pass-c-format --flag=_:1:pass-d-format’
Formatting with positions
‘fprintf "%2$d %1$d"’, ‘format "%2$d %1$d"’
Portability
fully portable
po-mode marking
--
An example is available in the ‘examples’ directory: ‘hello-d’.