[Tutor] What/Why this Cookbook recipe?
Andrei
project5 at redrival.net
Thu Mar 8 19:25:54 CET 2007
> > - format strings can be used to translate an application. You just give
> > the translator your 'Name: %s' string and he gives you 'Borkbork: %s' or
> > whatever. The translation doesn't need to be modified if you decide to
> > make a user class and get rid of the username and userage vars.
> >
> I don't see what you mean here. The string in the example,
>
> interp('Name: #{username}\nAge: #{userage}')
>
> could be translated too.
Yep, it could. However, it exposes a few dangers that the normal format string
doesn't. Of course there are workarounds possible (like checking the
translations manually or writing a tool for doing it automatically, or having a
very good translation tool), but it's not the optimal solution.
- the translator is more prone to make an error in the translation because of
the relatively complex syntax
- the translator has the power to expose private information by substituting
other variables in there. Worst case behavior due to malevolent translation in
the case of format strings is a simple exception.
- and then there's the problem of having to manually update who knows how many
translations whenever you decide to rename a variable
On the other hand, having the variable name in there may give the translator
useful information about the way he should translate a string, as the
translation may be influenced by what will be filled in in the blanks. It's
always a trade-off, isn't it.
Yours,
Andrei
More information about the Tutor
mailing list