Two standard libraries?
Regan Heath
regan at netmail.co.nz
Mon Jul 16 09:38:20 PDT 2007
Sean Kelly wrote:
> Roberto Mariottini wrote:
>> Jarrett Billingsley wrote:
>> [...]
>>> Now look at a language like Japanese, where you'd probably put the
>>> database name first; it'd be arranged something like "in personnel
>>> database {}, employee {} does not exist". Now you have to change the
>>> order of the arguments after the format string. But with indexing,
>>> you can say {0} always is the employee name, and {1} always is the
>>> database name, so that you can format them in the correct order for
>>> other languages, without having to change the actual format code.
>>> Just change the format string.
>>
>> May I suggest to use an identifier instead of a numeric index?
>> I have several years of experience with multi-language code and I can
>> say that for a translator is better.
>>
>> For example:
>>
>> "{0} has {1} pieces in {2}"
>>
>> Could be:
>>
>> "{supplier} has {stock} pieces in {city}"
>>
>> and make the translator happy.
>
> How would such identifiers be matched up with variadic arguments?
hmm.. Could it match the variable names with the inserts?
string supplier = "Bob";
string city = "Someplace far far away";
int stock = 5;
format("{supplier} has {stock} pieces in {city}",
supplier, city, stock);
Maybe with some more reflection features it could be possible.
Regan
More information about the Digitalmars-d
mailing list