Recent

Author Topic: Localization of Slavic plurals?  (Read 1763 times)

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Localization of Slavic plurals?
« on: November 08, 2024, 12:25:44 pm »

AFAIK, PO supports the translation of numbers in Slavic languages.
Shortly the issue is that in some Slavic languages if the number ends with “one”,“two”,“three” or “four” the plural form is different than in the other cases.
I found no info on how to handle it in Lazarus.
Shall I use Format or some other function? And shall I handle it manually in the POT files or can it be handled automatically?
I use
Code: Pascal  [Select][+][-]
  1.    resourcestring
  2.    lngSomeString = '%d files found';

Edit: It occurs that I have mentioned this in 2013, but it was not answered.

« Last Edit: November 08, 2024, 12:49:27 pm by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

domasz

  • Hero Member
  • *****
  • Posts: 553
Re: Localization of Slavic numbers?
« Reply #1 on: November 08, 2024, 12:37:34 pm »
In Polish we translate this way:

Code: Pascal  [Select][+][-]
  1. lngSomeString = '%d plik/ów znaleziono';

Or write a specialized function.

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Localization of Slavic plurals?
« Reply #2 on: November 08, 2024, 01:15:44 pm »

PO is designed to support such cases.
Just think about your own example:

lngSomeString = '%d plik/ów znaleziono';



You might need 3 separate cases:
  1. When there is a single item (1 plik).
  2. When there are 2 to 4 items (3 plikow)
  3. When there are 5 to 20 items (9 plika)


Here is some info, item 12.6.
https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html


Code: Pascal  [Select][+][-]
  1. #, c-format
  2. msgid "One file removed"
  3. msgid_plural "%d files removed"
  4. msgstr[0] "%d slika je uklonjena"
  5. msgstr[1] "%d datoteke uklonjenih"
  6. msgstr[2] "%d slika uklonjenih"

Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

domasz

  • Hero Member
  • *****
  • Posts: 553
Re: Localization of Slavic plurals?
« Reply #3 on: November 08, 2024, 02:17:23 pm »
Here's the thing- translating perfectly is super hard. So 99% companies, even Polish ones, don't care.
"5 plik/ów" is fine.
Yes, you could make a perfect translation of this but then you should make perfect translations of all similar cases, and there is a lot of them in Polish.
For example- programs often welcome users or use their names in other cases:
Hello, Tom!
Good morning, Tom!
Thank you for your purchase, Tom!
In Polish you should use declension and rules for declensions of names are super complicated:
Dzień dobry, Tomaszu! (Tomasz)
Dzień dobry, Anno! (Anna)
Dzień dobry, Hubercie! (Hubert)
Dzień dobry, Sławomirze! (Sławomir)
Dzień dobry, Jacku! (Jacek)
Dzień dobry, George'u! (George)
Dzień dobry, Stevenie! (Steven)

ackarwow

  • Jr. Member
  • **
  • Posts: 74
Re: Localization of Slavic plurals?
« Reply #4 on: November 08, 2024, 10:27:59 pm »
Perhaps there is another way, even less complicated: 'number of found files: %d' which in Polish can be translated as 'liczba znalezionych plików: %d'.

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Localization of Slavic plurals?
« Reply #5 on: November 09, 2024, 08:24:24 pm »

Here's the thing- translating perfectly is super hard. So 99% companies, even Polish ones, don't care.

Well, I will reference the Polish  ;D writer Stanislaw Lem: „The prevalence of the infringement cannot justify it“.


Perhaps there is another way, even less complicated: 'number of found files: %d' which in Polish can be translated as 'liczba znalezionych plików: %d'.

Thanks for the proposal, but I am not looking for an workaround (yet).
I am trying to find out if it is possible to make the things properly with Lazarus.
The wheel is already invented and specified, the question is if it is implemented in Lazarus.
« Last Edit: November 09, 2024, 08:27:53 pm by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

TRon

  • Hero Member
  • *****
  • Posts: 3619
Re: Localization of Slavic plurals?
« Reply #6 on: November 09, 2024, 08:38:24 pm »
I am trying to find out if it is possible to make the things properly with Lazarus.
The wheel is already invented and specified, the question is if it is implemented in Lazarus.[/size]
Yes it is possible. No it isn't already implemented (*).

There are many languages that uses different prefix and/or suffix or some alternative form of expression for different numbers.

So, while strictly speaking it is possible to add support it depends on the language. Sometimes a implemented function takes care of the difference in the English language between 1 and other numbers but I experience that as being out of the ordinary already. It is much easier to use the form: "number of files found is 0"

(*) There might be a 3th party component that is capable of automating this (and which I am not aware of). There used to be a autotranslate component for Delphi which could have done as such when extended).
« Last Edit: November 09, 2024, 09:05:21 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Zoran

  • Hero Member
  • *****
  • Posts: 1882
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Localization of Slavic plurals?
« Reply #7 on: November 09, 2024, 10:27:54 pm »
Here is what I use in code, might be useful, albeit not be very elegant.
Not really interesting for non-slavic languages.

Code: Pascal  [Select][+][-]
  1. function JedninaDvojinaIliMnozina(N: Integer;
  2.   const SJednina, SDvojina, SMnozina: String): String;
  3.  
  4. begin
  5.   if N < 0 then
  6.     N := -N;
  7.  
  8.   N := N mod 100;
  9.  
  10.   if (N >= 11) and (N <= 14) then
  11.     N := 0;
  12.  
  13.   case N mod 10 of
  14.     1:
  15.       Result := SJednina;
  16.     2..4:
  17.       Result := SDvojina;
  18.   otherwise
  19.     Result := SMnozina;
  20.   end;
  21. end;
  22.  

Then you can use it like this (example in Serbian):
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Prikaz(BrojProlaznika: Integer);
  2. const
  3.   Poruka1: String = 'Прошао је %d човек.';
  4.   Poruka2: String = 'Прошла су %d човека.';
  5.   Poruka0: String = 'Прошло је %d људи.';
  6. begin
  7.   Label1.Caption :=
  8.     Format(JedninaDvojinaIliMnozina(BrojProlaznika, Poruka1, Poruka2, Poruka0), [BrojProlaznika]);
  9. end;
  10.  

Edit: Added small project which shows the usage.
« Last Edit: November 09, 2024, 10:39:34 pm by Zoran »

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Localization of Slavic plurals?
« Reply #8 on: November 11, 2024, 11:27:50 am »
I was thinking about something like that as a workaround.
Just a question, please confirm that “Прошао је 21 човек.“ and “Прошао је 31 човек.” is correct? I want to be sure that it is not a software error.



Code: Pascal  [Select][+][-]
  1. Прошло је 0 људи.
  2. Прошао је 1 човек.
  3. Прошла су 2 човека.
  4. Прошла су 3 човека.
  5. Прошла су 4 човека.
  6. Прошло је 5 људи.
  7. Прошло је 6 људи.
  8. Прошло је 7 људи.
  9. Прошло је 8 људи.
  10. Прошло је 9 људи.
  11. Прошло је 10 људи.
  12. Прошло је 11 људи.
  13. Прошло је 12 људи.
  14. Прошло је 13 људи.
  15. Прошло је 14 људи.
  16. Прошло је 15 људи.
  17. Прошло је 16 људи.
  18. Прошло је 17 људи.
  19. Прошло је 18 људи.
  20. Прошло је 19 људи.
  21. Прошло је 20 људи.
  22. Прошао је 21 човек.
  23. Прошла су 22 човека.
  24. Прошла су 23 човека.
  25. Прошла су 24 човека.
  26. Прошло је 25 људи.
  27. Прошло је 26 људи.
  28. Прошло је 27 људи.
  29. Прошло је 28 људи.
  30. Прошло је 29 људи.
  31. Прошло је 30 људи.
  32. Прошао је 31 човек.
  33. Прошла су 32 човека.
« Last Edit: November 11, 2024, 11:38:14 am by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

Zoran

  • Hero Member
  • *****
  • Posts: 1882
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Localization of Slavic plurals?
« Reply #9 on: November 11, 2024, 02:27:29 pm »
I was thinking about something like that as a workaround.
Just a question, please confirm that “Прошао је 21 човек.“ and “Прошао је 31 човек.” is correct? I want to be sure that it is not a software error.

Yes, that is correct in Serbian. But note that numbers between 11 and 14 have different rules (these act as if they don't end with 1..4)! I'm not sure if it is same in Bulgarian though.
« Last Edit: November 11, 2024, 02:32:47 pm by Zoran »

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Localization of Slavic plurals?
« Reply #10 on: November 11, 2024, 09:05:55 pm »

...

 But note that numbers between 11 and 14 have different rules (these act as if they don't end with 1..4)!...

Yes, I know it, but that is only because I have studied Russian.

... I'm not sure if it is same in Bulgarian though...
No, we do not have such a thing in Bulgarian, possibly maybe only in some westmost dialects. Bulgarian and Serbian vocabularies is very close but grammar is very different.

Indeed, some Slavic languages are harder to handle, but as far as I understood, since Lazarus does not have internal support for switching singular and plural, probably Turkic, Korean, Japanese and Chinese are the only languages with proper support. Actually I am almost sure about Turkish, I am just guessing for the other ones.
According to Google Translate, Hungarian is also more complex in that aspect.

Also, format ('asdfasfsad %d ASDFASF sas %d af',['string1','string2'); does not seem proper, because when a string is translated string1 might occur after string2.
« Last Edit: November 11, 2024, 09:11:19 pm by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 16138
  • Censorship about opinions does not belong here.
Re: Localization of Slavic plurals?
« Reply #11 on: November 12, 2024, 02:40:21 pm »
Hungarian is just plain weird to me and is related to two other bonkers languages I can not get to grip with: Estonian and Finnish. And I am a bit of a polyglot. These languages simply baffle me. Can't get to grips with it. But most Hungarians speak either Engish, German or Russian and it is an absolutely beautiful country with nice people - and food!
The languages mentioned by me are NOT Slavic, they are Uralic.
« Last Edit: November 12, 2024, 02:42:59 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

backprop

  • Full Member
  • ***
  • Posts: 101
Re: Localization of Slavic plurals?
« Reply #12 on: November 12, 2024, 02:43:58 pm »
Bulgarian and Serbian vocabularies is very close but grammar is very different.

Actually, each Slavic language have it's own rules, as any other language in the same group. And all evolving/degrade due time. Some written and spoken rules was quite different than in modern time.

Also, it is not fair to expect any programming language to have such heuristic libraries and also which is 100% accurate. It is on you to make your own solution, but that depends quite a bit of literary knowledge, database of words, exceptions... Quite a bit of work.
« Last Edit: November 12, 2024, 02:50:53 pm by backprop »

CM630

  • Hero Member
  • *****
  • Posts: 1191
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Localization of Slavic plurals?
« Reply #13 on: November 18, 2024, 01:53:05 pm »

I named the thread “Slavic”, because I knew that PO has conventions for them.
But actualy the issue occured to have a wider scope.
Generally:
  In Turkish things are not very complex (if I am not wrong):
0 dosya
1 dosya
2 dosya
3 dosya
4 dosya
5 dosya
6 dosya


  In English it is more complicated:
0 files
1 file
2 files
3 files
4 files
5 files
6 files
 
  In Russiаn it is even more (according to google):
0 файлов
1 файл
2 файла
3 файла
4 файла
5 файлов
6 файлов
21 файл


  About Hungarian Google says:
0 fájl
1 fájl
2 fájl
3 fájl
4 fájl
5 fájl
6 fájl
21 fájl


  But if I change “file” to “men”, Turkish and Hungarian become more complex:
0 erkek
1 adam
2 adam
3 adam
4 adam
5 adam
6 adam
21 erkek


0 férfi
1 ember
2 férfi
3 férfi
4 férfi
5 férfi
6 férfi
21 férfi


  And Hungarian becomes even more complex if I change “file” to “pig” (Btw, I am aware that Hungarian is not a Slav language, not even Indo-European, I mentioned it because I did not know what to expect from it):
0 sertés
1 malac
2 malac
3 malac
4 malac
5 malac
6 malac
21 sertés
25 sertés


Almost all of these are translated with Google translate, so they might be wrong.


So I get the impression, that resourcestring should rather be TStringList, an array of string or something similar. But it is a string.
But even if it was so, some issues might not be standardizable.
For example: “Your search has found X file in Y folder”.
  Both X and Y might be singular or plural so that makes 1 case for Turkish, 4 cases for English and even more (9 if I am not wrong) cases for Russian.
  Also, Y might come before X in some languages, because of the word order. That does not sound so problematic, some custom Format would do.


And I wonder if I should mark the issue as [SOLVED] or [UNSOLVABLE) ;)
« Last Edit: November 18, 2024, 01:56:01 pm by CM630 »
Лазар 4,0RC1 32 bit (sometimes 64 bit); FPC3,2,2

af0815

  • Hero Member
  • *****
  • Posts: 1378
Re: Localization of Slavic plurals?
« Reply #14 on: November 18, 2024, 02:43:26 pm »

0 férfi
1 férfi
2 férfiak
3 férfiak
4 férfiak
5 férfiak
6 férfiak
21 férfiak

Actual i am learning hungarian -> singular is férfi and plural is férfiak. Ember is people/human. But 0 is often nincs férfi called.

German is here the same -> singular is Mann and plural is Männer. And 0 ist kein Mann or niemand
regards
Andreas

 

TinyPortal © 2005-2018