D Conference Tango Phobos

Derek Parnell derek at psych.ward
Sat Sep 15 03:18:10 PDT 2007


On Sat, 15 Sep 2007 10:57:35 +0100, Janice Caron wrote:

> The string value returned by translate[NAME] should not need to be
> aware of what variable names are later going to be substituted into it
> (which might in any case be different at different points in the
> program).
> 
> The model is, programmers write the code, then translators provide the
> international translations. The goal is to minimise the dependency
> between the two. Therefore, I believe that substitution by argument
> index is the right thing to do.


For what its worth, I have coded a routine called Expand. It is used thus
...

   result = Expand("Prenom {fn}, Nom {ln}", 
			"fn", firstname, "ln", name);
   result = Expand("Surname {ln}, First name {fn}", 
			"fn", firstname, "ln", name);

Where tokens, such as {fn} and {ln} in this example, are used to locate
keys with the same value in the argument list. The argument to the right of
a key is it's associated value. The values are used to replace their
respective embedded tokens in the format string. If the arguments do not
match any token in the format string, the token is just removed from the
output.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list