Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] I18N for word forms: a modest proposal
Home

[Freeciv-Dev] I18N for word forms: a modest proposal

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] I18N for word forms: a modest proposal
From: Dmitriy Genzel <dg@xxxxxxxxxxxx>
Date: Fri, 18 Feb 2005 14:01:20 -0500 (EST)

I'd like to propose a relatively painless method to allow for translation
of word forms in those languages that have them. The method requires only
a little work for developers {when marking things for translation), and
just the required amount of work for the translators of the languages
that care to implement this. I undertake to implement the changes in the
code, if the proposal is accepted.

BACKGROUND

Somewhere in the code there's a string like this:
  "Upgrading this %s would strand units it transports."
The %s presumably corresponds to a unit name. The problem is that in most
languages that have at least 2 cases, this unit name would be in
accusative, except it's impossible to do so. Presumably you might try to
rephrase the sentence, but it might not be possible.

PROPOSAL

Here's what the changes would look like from the developer's point of
view:

Instead of
  sprintf{s,_{"Upgrading this %s would strand units it transports."},unit)
one writes
  SPRINTF{s, "Upgrading this ?unit:%s would strand units it transports.",unit}
or something like it

Here's what it looks like for translator:
msgid "Upgrading this ?unit:%s would strand units it transports."
msgstr " .... .... ?accusative:%s ..... ..."

msgid "?unit:Caravel"
msgstr "Karavella"     # as before

# maybe in a separate file or gettext domain?
msgid "?accusative:Karavella"
msgstr "..."

Naturally, all msgids will be pregenerated, even though
?accusative:Karavella never occurs in the code.

NOTES ABOUT IMPLEMENTATION
Details need to be worked out, but here's the general idea:

a macro/function, called SPRINTF accesses gettext on format string, does
some manipulation on the resulting string to figure out which are string
arguments, and calls gettext on them, if necessary, and then calls normal
sprintf. Literal strings with no arguments, for which sprintf is not
called, are used as before. Notice that if an entry for Caravel exists,
{and is "Karavella"} but not one for ?accusative:Karavella, we'll simply
use Karavella, which is no worse off than we were before.

a bunch of scripts is needed, to produce the correct .pox/.po file{s} and
then maybe postprocess them before turning into .gmo. Note that the way
this works is as follows:

  The "Upgrading ..." string pair indicates that it needs a "unit" in an
"accusative" form. A Caravel is a unit {it needs to be marked as such
either by the developers, or automatically based on the file it comes
from} because there is a "?unit:Caravel" entry, so another entry is
produced for an accusative form of the translation of Caravel. And, of
course such an entry will be made for all units.

Notice that "accusative" label is strictly local to the language. If a
language has no need of an accusative, it simply won't use a label before
%s, and no extra translation would be needed.

Also, while I've been using ?...: format in the above example, we probably
want another format, to avoid confusion with qualified strings.

PROBLEMS AND ISSUES
This will require going over the strings using %s and change the macro
used around it. Perhaps this can be semi-automated.

All translators will see a bunch of fuzzy's, because some source strings
will change. However, we can provide a script to automate getting rid of
them if the language doesn't need this feature.

Finally, it won't solve all the problems, at least not that I can see. For
example, in a sentence like

  "Your ?unit:%s is victorious"

"Your" and "is" may need to be translated differently based on the gender
or number of the unit's name. At the moment this still can't be fixed


I am looking forward to your comments.

Dmitriy Genzel,
maintainer of ru.po



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] I18N for word forms: a modest proposal, Dmitriy Genzel <=