What's missing from Phobos for Orbit (package manager)
Johannes Pfau
nospam at example.com
Wed Feb 13 01:53:08 PST 2013
Am Tue, 12 Feb 2013 20:38:54 +0100
schrieb "qznc" <qznc at go.to>:
>
> There will always be multiple solutions on different levels of
> power and applications have to choose, which suits them best.
>
> My advice: If you find your self wanting that, try to rephrase
> first.
>
> For example, instead of "there are %d cat(s)" output "number of
> cats: %d". It will be much easier to internationalize.
The gettext approach works quite well: There's no pluralize function.
Instead you pass a singular and plural form and a number:
ngettext(string singular, string plural, int num).
Of course this works only for english strings, but that's what you use
in your source code:
writefln("Have %s %s", num, ngettext("message", "messages", num));
Other languages are handled transparently in the translation process:
The translator can specify as many plural forms as necessary. A language
specific formula then determines the correct plural form:
http://translate.sourceforge.net/wiki/l10n/pluralforms
More information about the Digitalmars-d
mailing list