preprocessing printf/regex strings (like ocaml)

Robert Ennals Robert.Ennals@cl.cam.ac.uk
Thu, 16 May 2002 09:50:47 +0100


> Robert Ennals <Robert.Ennals@cl.cam.ac.uk> wrote:
> > Surely that problem only arises if one insists on encoding all the relevant 
> > 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 don't really see what makes a string such as 

"I have %. %. %.."   [where the user has to work out what the substrings are]

any harder to deal with than

"I have " ++ action ++ " " ++ number ++ " " ++ whatas

other from the fact that the former is what C does.

A translator doesn't need to know Haskell. They just need to know that, when, 
in the messages module they see


englishword = "some string"

they put the translation of the word into the string.

And if they see a message like

msgname part otherpart = "string " ++ part ++ " string" ++ otherpart

They change the strings, and reorder the parts to make it a sensible sentence 
in the target language.


AFAICS the only reason to use printf strings is because that is what some 
people are used to, not because it is sensible system to be using.

i18n is a useful hack to retrofit onto the C printf system, but I think it 
would be a backward step for Haskell.


-Rob