Inflection aware messages

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Ignatus
Elite
Posts: 352
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Inflection aware messages

Postby Ignatus » Sat Mar 28, 2020 10:41 pm

This is not a gameplay related thread, we have many more important things to improve, but if we had better messages language, it would surely please us.

Currently, all things and figures in Freeciv that should be named in messages have only one string that is used as their name. Nations have two strings, name and adjective, but they are mostly translated as the same, probably because no one can get the idea when each one is used (I judge by Russian translation). This sometimes might lead to broken language even in English; if we have a message "Your %s has not enough movepoints left to perform %s now", the first %s is good for "Spy" but requires "have" verb for "Archers", and _PL() function can't help here. Also, we would like at the end "establish trade route" better than "perform Establish Trade Route". There are gender languages, as French, where we might sometimes mind if our Spy is female or male. CivIV XML files have gender and number specifications for each translation of each unit name. But there are case languages, say Russian, where you must inflect nouns and adjectives depending on their role in the sentence and the words they are related with.

How message writers get around now: in Russian, all messages mentioning units and nations do it after words, correspondingly, "soyedineniye" and "narod" used in the appropriate form in the message. Using the nominative case for the noun in this context is more or less plausible Russian but very far from excellent.

I don't know any particular gettext extension that can cope with this problem. I can only imagine how it would look. Say, in the message table we have
"Your <%s [has]> not enough movepoints left to <[?p:v=|perform] %s> now"
that is translated to Russian as
"У <[c=g][ваш] %s> недостаточно очков движения, чтобы сейчас <[?p:v=|выполнить[c=a] ]%s>"
For the units and actions, we have in English
"Archer[s]"
"Sp[y][g=f]" ;gender for "he/she/they" in some msgs
"establish[ING] trade route<[?Nroutes:sg|pl=[N=Nroutes]|[N=sg]][S]>[p=v]"
"bombardment[S][p=n]"
and in Russian
"Лучни[ки][a=a][g=m]"
"Шпион[Ы][a=a][g=m]"
"установ[ить] <[?Nroutes:sg|pl=[N=Nroutes]|[N=sg]]торгов[ый] [путь]>[p=v]"
"бомбардиров[о?][ка][p=n]"
The flexion definitions would contain for English langpack

Code: Select all

has=[!N:sg][!t:PresI][t:i=have|Past*=had|G=having|[?N:pl=have|has]]
s=[!N:pl][?N:pl=s]
S=[!N:sg][?N:pl=s]
y=[!N:sg][?N:pl=ies|y]
ING=[!t:i][?t:*C|G=ing]

and for Russian langpack

Code: Select all

V=(Ci:аоуыэяёюие)
к=[!N:sg][!g:m][?N:sg=[?c:g=ка|d=ку|a=[?a:a=ка|к]|i=ком|p|l=ке|к]|[ки]]
ка=[!N:sg][!g:f][?N:sg=[?c:g=ки|d=ке|a=ку|i=кой|p|l=ке|ка]|[ки]]
ки=[!N:pl][?N:sg=[?g:f=[ка]|n=[ко]|[к]|[?c:g=ков|d=кам|a=[?a:a=ков|ки]|i=ками|p|l=ках|ки]]
ы=[!N:pl][?N:sg=[?g:f=[а]|n=[о]|[Ы]]|[?c:g=[?d:1=|ов]|d=ам|a=[?g:m=[?a:a=ов|ы]|ы]|i=ами|p|l=ах|ы]]
Ы=[!N:sg][!g:m][!d:2][?N:pl=[ы]|[?c:g=а|d=у|a=[?a:a=а|]|i=ом|p|l=е]]
ить=[!t:i][?t:Past=ил[?N:pl=и|[?g:f=а|n=о]]|i=ить|Imp=[?@-1:/(Ci:[V])/=й|и][?N:sg=|те]|[!pe:3][?pe:2=[?N=sg:ишь|ите]|1=[?N:pl=им|[?@-1:б|в|м|п|ф=л]ю]|[?N=pl:ят|ит]]]
ый=[!N:sg][!g:m][?N:pl=[?c:g=ых|d=ым|a=[?g:m=[?a:a=ых|ые]|ые]|i=ыми|p|l=ых|ые]|[?g:f=[?c:g|d|i|p|l=ой|a=ую|ая]|[?c:g=ого|d=ому|a=[?g:m=[?a:a=ого|ый]|ое]|i=ым|p|l=ом|[?g:n=ое|ый]]]]
путь=[!N:sg][!g:m]<[d=3]пут[?N:sg=[?c:i=ём|[ь]]|[ь]]>[!a:i]
ь=[!N:sg][?N:pl=[?c:g=ей|d=ям|a=[?g:m=[?a:a=я|ь]|ь]|i=ями|p|l=ях|и]|[?g:m=[!d:2]|f=[!d:3]][?d:3=[?c:g|d|p|l=и|i=ью|ь]|[?c:g=я|d=ю|a=[?a:a=я|ь]|i=[ё]м|p|l=е|ь]]]
о?=[@+/\w*/:/[V]/=|о]

A function that has flexion tables preloaded from a langpack would get the flexible strings assembled with sprintf() and interpret the code (e.g. [variable to substitute], [variable=value to set], [!variable:value if not set], <zone of local variables>...). The syntax may be as simple as it's shown ;) and suitable for virtually any language, all differences are in the conventions of what variables serve for what purpose in a specific langpack (e.g. "c" codes case, "g" for gender, "t" for tence...). The problem is that translators don't swarm around, and using system like this (if nobody can find a database or write a script to auto-import language flexioned dictionary from Wiktionary) requires loads of time and at least basic linguistic education.

jwrober
Posts: 18
Joined: Thu Jul 11, 2019 2:05 pm

Re: Inflection aware messages

Postby jwrober » Mon Mar 30, 2020 6:30 pm

I wonder how other OSS projects handle i18n? Freeciv could piggyback on those efforts. Is there some kind of library we could use?

Wahazar
Elite
Posts: 344
Joined: Mon Jul 02, 2018 1:49 pm

Re: Inflection aware messages

Postby Wahazar » Mon Mar 30, 2020 6:51 pm

jwrober wrote:I wonder how other OSS projects handle i18n? Freeciv could piggyback on those efforts. Is there some kind of library we could use?

I like system implemented in OpenTTD:
http://bundles.openttdcoop.org/eints/ni ... usage.html
Everybody can work on given translation, which is automatically merged into main project.
Translator support genders, cases, plural forms etc:
https://bundles.openttdcoop.org/eints/n ... rings.html
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047