On Wed, 29 Mar 2000, Matthias Mann wrote:

> Has anybody some experience on what's the best way to write programs that may 
> interact in multiple languages?
> 
> My first thought was to extract all texts from the source and put them into a 
> big list or array. The program then accesses the list corresponding to the 
> selected language.
> 
> Any other (better) ideas? Should inputs, e.g. answers to yes-no-questions, be 
> handled the same?

Not sure if this is a better idea, but the approach that, from what I can
gather, a lot of the GNU programs use is equivalent to replacing every
literal string in the text with roughly

(lookup language "the string")

where lookup::Langauge -> String -> String and language is (in C) a global
variable containing the target language. These strings get looked up at in
an external set of translations for various languages at runtime (ie once
for each time the string is called) and if a translation is found it's
used, otherwise the original string is used. The advantages of this seem
to be that (1) translators can provide extra translations without needing
a program recompile and (2) it's failsoft so that if there's no
translation there's still a string to use, albeit in the language the
programmer used and (3) with the _(x) macro it doesn't add `visual noise'
to the program logic. The disadvantage of this kind of scheme for haskell
is that there's no way to get a user setable global variable without
everything going monadic (or you use an unsafe operation) so it'd have to
be passed as an explicit argument to every function needing it. Presumably
with answers the user types (as opposed to GUI components with labels that
they activate) I guess you're into the realm of regular expressions rather
than strings.

I'd be interested to know if there's a more natural way to do this for
haskell.

___cheers,_dave________________________________________________________
www.cs.bris.ac.uk/~tweed/pi.htm|ALERT: you are communicating with an
email: [EMAIL PROTECTED]     |unsavoury individual with a copy of gdb
work tel: (0117) 954-5253      |who reverse-engineered a file format.


Reply via email to