preprocessing printf/regex strings (like ocaml)

Martin Norbäck d95mback@dtek.chalmers.se
16 May 2002 15:06:55 +0200


tor 2002-05-16 klockan 10.50 skrev Robert Ennals:

> 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.

Because in one case you just need to change the string, which is in a
database separate from the program, in a standard format (po).

We could have some other syntaxes which makes things clearer, like

printf_named "I have %action; %number; %whatas;."
  [("action","trained"),("number", show 1), ("whatas", "Jedi")]

In the other case you need to change the program, and recompile. So in
the second case you need one compiled program for every language you
support.

If your volonteer translators have to compile the program as well, you
might not get any translations at all due to the high barrier compiling
is.

> 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.

I have experience with different systems for translation. If you
translate a number of programs (like I've done), you come to appreciate
that they use the same system.

Gettext is the by far most used system, and it has a lot of nice
properties, like the ability to translate an application without having
to recompile it and good tool support.

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

Since I've never seen any i18n systems for Haskell, everything would be
a step forward.

Regards,

	Martin

-- 
Martin Norbäck          d95mback@dtek.chalmers.se              
Kapplandsgatan 40       +46 (0)708 26 33 60                    
S-414 78  GÖTEBORG      http://www.dtek.chalmers.se/~d95mback/
SWEDEN                  OpenPGP ID: 3FA8580B