std.locale
Derek Parnell
derek at psych.ward
Mon Mar 2 18:10:30 PST 2009
On Mon, 02 Mar 2009 07:02:10 -0800, Andrei Alexandrescu wrote:
> Consider some code in phobos that must throw an exception:
>
> throw Exception("File `%s' not found, system error is %s.",
> filename, errnomsg);
>
> The localized version will look like this:
>
> auto format = "File `%s' not found, system error is %s.";
> auto localFormat = currentLocale ? currentLocale.peek(format) : null;
> if (!localFormat) localFormat = format;
> throw Exception(localFormat, filename, errnomsg);
One problem with this approach is that we meet the limitation of the
formatting string's micro-syntax. Currently, there is no way to reorder the
tokens in a message string, and that is required for /some/ messages in
/some/ languages.
I have used my own text formatting routine rather than Phobos' because it
allows the implementer to develop messages whose word order is correct for
their target language.
--
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
More information about the Digitalmars-d
mailing list