Translation of nummeric values (application gnome-schedule)



Hi there,

Because our application uses numeric nth values like 'first',
'second', ... a lot and because translating "1th" "2e", .. is 'also'
non-trivial, we decided to implement something that translates a numeric
nth to a written version of the value.

Since this makes it harder for translators to get this correct in their
own language, I decided to crack the code for it out of the project and
put it in a file which we call 'src/lang.py'.

You can find it here:
http://cvs.gnome.org/viewcvs/gnome-schedule/src/lang.py?rev=HEAD&view=auto

As you can see in the file it has been made very easy to implement the
functionality for your own language. Provided that you know how to write
such numeric values in your own language and provided you make sure that
every possible nummer > -100 and < 100 gets translated correctly.

I have implemented the functionality for English and added a not 100%
correct version for Dutch (perhaps some minor spelling problems exist,
will test and fix these later). Gaute Hope is implementing the
functionality for his language.

If there is a 'real' solution for this type of translations, I would be
glad to hear about it. In 'any' other case we are keeping this
implementation. Note that we don't count writing two hundred strings in
some include-file as a 'real' solution. As a solution, that sucks. For
translators it 'also' sucks translating two hundred strings. And the
size of the po-directory would dramatically increase once lots of
languages get supported.

I am, however, open for suggestions.

I made the English words translatable in case a language can get support
easily by just translating these words (first, second, third, ...). But
check the functionality first. Yeah the routine is very VERY easy to
understand. So easy that a person who has never seen a computer in his
live will understand whats going on. No really I am serious about that.

ps. If there is no such library function I propose the creation of such
a library function in GNOME or Gtk+. It's better that the toolkits
support and maintain something like this.

Other than that, gnome-schedule will now translate the crontab record

"33 * * * * ls # Untitled"

to 

---------- - - -
_("Untitled")
---------- - - -
_("Every %s minute of every hour")
o. Where %s is _("%s%s%s%s") 
o. And those four %s are:
_(""), _("thirty"), _("-"), _("third"), _("")
---------- - - -
 "ls"
---------- - - -

Other such frequency settings will also work, of course. The "33" to
"thirty-third" translation is being done by the functionality in "lang.
py". The words "thirty" and "third" are translatable using the po-files.
But some numeric nth values will not be translatable correctly to all
languages this way. A good example is the Dutch language: Correctly
translated to dutch would be "drieëndertigste". Well, I could have get
it almost right using po files for Dutch in many cases, thats because I
create the string using this:

(_("%s%s%s%s%s") % (_(""), tennumber, _("-"), remainder, _("")))


where tennumber is "dertig", and remainder "drie" (thats translated to
English: "thirty" and "three"). In the po file the "-" would have to be
translated to "ën" and the last empty string would have to be translated
to "ste".

You would get

dertigëndrieste

If I translate that non-existing word to English it would sound like
third-thirty, in English that would still work as a score between two
sporting teams. Well, not in Dutch, really. Dertigëndrieste sounds more
like a foreign name to us than a number. I see the German name "Dries"
in it, not sure if "Dries" is a German name :-).

Lets now use an English name and try again: Now in English the word is
more like thirtyronaldmcdonaldth.

It proves that po files will not do the job in this case.

!! But I 'did' added two empty translatable strings and made the "-"
translatable for languages that will get translated this way.

I did this 'just' to silence translators who are going to complain about
the complexity of getting it translated by implementing the
functionality in the "lang.py"-file :-)!



-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
work: Philip dot VanHoof at cronos dot be
http://www.freax.be, http://www.freax.eu.org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]