Re: internationalization

Dumas Patrice <[email protected]> Mon, 8 Sep 2003 19:06:24 +0200
Newsgroups gmane.comp.tex.texi2html.devel
Message-ID <[email protected]>
> Awesome, but are you talking about something like gettext's %1, %2, %3?
> Simply having a translator enter %s in their string won't allow for
> changing the order of substitutions and a quick search/replace is
> trivial in Perl.

The translator has to enter things like %2$s. But it is the same for gettext. 
This is an excerpt from the getext manual:
    
    Assume we
    have the code

          printf (gettext ("String `%s' has %d characters\n"), s, strlen (s));

.......snipped....

    If the word order in the above German translation would be correct one
    would have to write

         "%2$d Zeichen lang ist die Zeichenkette `%1$s'"

    The routines in `msgfmt' know about this special notation.

> Perhaps we could even use %{varname} or the like in the strings to make
> it easier for translators to read.  Passing a hash of the form <var1> =>
> <val1>, <var2> => <val2>, ... to the translation and then the
> search/replace function is pretty straightforward in Perl as well.

I agree that it would help, but I can't see how to do that practically.
Imagine there is the following string

"See section %s in %s"

I agree that it would be nicer if it was possible to know that the first %s
corresponds to 'section_name' and the second %s corresponds to 'book'. Is it
what you proposed ?

If yes, do you have an idea on how to do it practically ?

> Is the reference has necessary for purposes other than documentation?
> IIRC, gettext simply uses the english "key" string if no translation is
> available.  

This is what is done here, too.

> This way the english strings would only need to be stored in
> one location.  If you want to be able to generate "templates" for
> translators and obsolete translations for keys which are no longer in
> use, I'd think the keys could be stripped from the calls to the
> translation functions fairly easily.

I don't understand that... Do you mean that the strings should be stored
only in the code, and the templates would be regenerated by parsing the code
for strings to be translated ? 

In my scheme, there is no such thing. When
a string is an argument to the translation function and this string isn't
in the reference hash, a warning is echoed. I think that it is enough
for detection of new strings. However there is nothing to detect that a
string in the reference hash is no longer in use.

> |One
> |of the hash holds the strings appearing in the reference hash. The other
> |contains all the obsolete strings which are not in the reference hash
> anymore.
> |These hashes are automatically updated with
> |$./texi2html -i18n update
> 
> 
> Why is this part of texi2html and not the build tool or even a
> maintainer-only script?  I don't think any functionality a user won't
> need access to should be part of the texi2html script.

You are right I will make it a separate script. All the real code is in 
T2h_i18n.pm anyway. I was just lazy...

> Again, why not handle this in the build tool?  It should be as easy, if
> not easier, to include i18n/* without the intermediate translations.pl
> step.  

I added that file because I wanted to use AC_SUBST_FILE in configure.in.
Maybe we could use another technic ? 

> If you were planning on allowing for overrides, why not allow an
> installed TEXI2HTML_LIB/i18n/* file to override rather than a single
> translations.pl?  

That is not for overriding at all. The overriding should happen in init 
files, wherever the defaults come from.

> I think the translations.pl file overly complicates
> matters.

I agree but I haven't any other idea.

Pat