preprocessing printf/regex strings (like ocaml)

Martin Norbäck d95mback@dtek.chalmers.se
15 May 2002 21:58:36 +0200


tis 2002-05-14 klockan 18.56 skrev anatoli:
> Robert Ennals <Robert.Ennals@cl.cam.ac.uk> wrote:
> > Surely that problem only arises if one insists on encoding all the rele=
vant 
> > information inside a string.
> 
> This is pretty much the only option, because translators
> and programmers are different people. Translators can deal with
> simple text files with one message string per line and not
> much else. You can't hire a translation firm and tell them
> "translate this Haskell module for me".
> 
> You can treat message strings as declarations in a specialised
> language. This language can be typed, and you could theoretically
> typecheck it against your Haskell program using specialised tools.
> But translators need to see simple readable message strings.

I played around with this some more. You can see some files at
http://www.dtek.chalmers.se/~d95mback/gettext/ if you are interested.

The use of unsafePerformIO may be unsafe here, I really haven't got a
clue.

When in doubt, use i18n instead of __ :)

Output examples:

martin@lexie:~/gettext$ LANG=sv_SE ./Main
Hej världen!
1 Jedi trained I have.
martin@lexie:~/gettext$ LANG=en_US ./Main
Hello, world!
I have trained 1 Jedi.

Regards,

	Martin