|
From: Bruno H. <br...@cl...> - 2004-05-26 17:27:48
|
Hi, > I maintain a bash script (http://speedtouchconf.sourceforge.net/) - > recently a user sent me an Italian version of the script. > > I've done my best to create an i18n'ised version of the script, to use > the input. I suspect that I've lost something in the cut'n'paste, though. > > The contributor sent me a modified version of my source Of course, a special version of the source for each language is not maintainable. > I've cut'n'pasted it into an it.po file, and it "works" in that the script > now displays his Italian translations instead of my English. > It just doesn't look "right" to me, though - I'd send a screenshot if > reinstalling RedHat hadn't screwed it up. > Basically, if I log in with an Italian language set, I see accented > characters, etc, as something more like "e'" than an "e-acute" symbol > I'd expect to see. That's only a problem in your setup: You don't have the environment variables set up for use of Italian. (The way to set LANG etc. is explained in gettext's ABOUT-NLS file.) See also http://www.haible.de/bruno/gettext-FAQ.html#translit > All the code is as at the above URL, so I won't spam this alias with > code - I'm totally new to i18n, what am I doing wrong? I take the opportunity to send you back modified sources with the following changes: - Use the gettext.sh functions, instead of bash's $"..." builtin. This is not only more portable, it also avoids security problems in the $"..." construct that cannot be fixed. - Prefix all variable references in internationalized strings with a backslash. This is needed since you want the message to be looked up in the catalog before doing the variable substitution, not afterwards. - Use symbolic variable references instead of numeric variable references. This is not only necessary because eval_gettext is implemented as a shell function, it's also easier to translate for the translator. - Use a more standard layout of the po/ directory. This assumes that your users will use the script after installing it. If the users should use it without installing, then your original directory structure with po/$language/LC_MESSAGES/$domain.mo is the right one, however. (But you don't need a directory for the C locale or symlinks like en_GB - the gettext primitives already handle this stuff.) I haven't tested my changes; for some code that works, look at the hello-sh example in the gettext-0.14.1 distribution. Bruno |