std.locale

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Mar 2 18:36:09 PST 2009


Derek Parnell wrote:
> 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.
> 

Phobos has supported Posix positional syntax since 2.006.

http://digitalmars.com/d/2.0/phobos/std_stdio.html


Andrei



More information about the Digitalmars-d mailing list