«Plural Forms»: الفرق بين المراجعتين

من ويكي عربآيز
اذهب إلى: تصفح، ابحث
ط
 
(12 مراجعة متوسطة بواسطة 5 مستخدمين غير معروضة)
سطر 1: سطر 1:
<div class=english>
 
 
 
{{Arabic|صيغ المعدود}}
 
{{Arabic|صيغ المعدود}}
  +
GNU Gettext is used by most free software as a localization framework, one of GNU Getext features is [http://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html plural forms].
   
 
== Plurals ==
The current plural form gettext equation used in Gnome, KDE and probably in other projects is wrong [5]. I know that QAC investigated this issues but it didn't decide on a definitive solution, so it is clear that the current plural form expression is a temporary hack and of course confirmed as wrong.
 
 
nplurals=4; plural=n==1 ? 0 : n==2 ? 1 :n>=3 && n<=10 ? 2 : 3;
 
 
In https://www.arabeyes.org/QacDecisions:
 
 
This GNU Plural Header will be used when we can find a way to script its functionality:
 
nplurals = 7; plurals = n==0 ? 0 : n==1 ? 1 : n==2 ? 2 :
 
n%100>=3 && n%100<=10 ? 3 :n%100==1 ? 5 : n%100==2 ? 6 : 4;
 
 
Arabic follows sophisticated rules to decide on the form of the "counted" items. Moreover, there are two distinct rules, one if numbers are read from the right to the left and an other if they are read from the left to the right, as the form of counted items follows the last number.Both rules are correct, studies confirm that in the past both rules were allowed, however reading from the right to the left - following the order of the letters in Arabic - is the more respected rule, and nowadays medias use reading from the left to the right.
 
Since there are two rules, we need decide on one and only one to use in the translations. Reading from the left to the right is not implementable at all as a gettext formula first, and second to substract 1 or 2 from the variable.
 
See [1]. Reading from the right to the left is implementable [2] and with
 
less cases (6) compared with (8) in the other. I am not sure if this is only correct if we assume that "101 كتاب" is read "واحد ومئة كتاب" and not "مئة كتاب وكتاب", see [2].
 
The current plural form is not clear, not documented and linguistically
 
wrong. 0 and a mysterious case (4th) were merged, the rule for numbers from 11-99 is not there.
 
Conclusion: The right-to-left form is the one to choose [2].
 
 
nplurals=6; plural=n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n >= 3
 
&& n <= 10 ? 3 : n >= 11 && n <= 99 ? 4 : 5;
 
   
  +
We are using now a 6 forms plural formula:
Plural forms 0, 1 and 2 don't require a variable, and here comes another issue. If two variables are included in the string, say %s and %d, and that %d is omitted this leads the application to crash (Segmentation fault) [3]. A solution exists, it is to use variable shuffling, which displays a correct result and doesn't crash [4]. This need be documented and tested for other implementations other than C. (Thank you Djihed for the idea)
 
  +
* First form: for 0
  +
* Second form: for 1
  +
* Third form: for 2
  +
* Fourth form: for numbers that end with a number between 3 and 10 (like: 103, 1405, 23409).
  +
* Fifth form: for numbers that end with a number between 11 and 99 (like: 1099, 278).
  +
* Sixth form: for numbers above 100 ending with 0, 1 or 2 (like: 100, 232, 3001)
   
  +
For Mozilla products (Firefox, Thunderbird, Sunbird, Fennec), the case where <code>n == 0</code> is shifted to become the last case (due to some backward compatibility with the older plural rule).
echo 'int main() { printf("%s \n", 2, "text");}' > test.c ;
 
gcc -w test.c -o output ; ./output
 
   
  +
== Plural formula ==
  +
This is the plural formula used for the forms above:
 
nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5;
   
echo 'int main() { printf("%2$s \n", 2, "text");}' > test.c ;
 
gcc -w test.c -o output ; ./output
 
   
  +
An exception for Mozilla products is:
 
nplurals=6; plural=n==0 ? 5 : n==1 ? 0 : n==2 ? 1 : n%100>=3 && n%100<=10 ? 2 : n%100>=11 ? 3 : 4;
   
One other issue is what form to use for non-integer numbers.
 
   
  +
== Examples ==
We may sometimes need to translate applications that don't support plural form for their simplicity, and use for example "user(s)" in English. I suggest to contact the developer and ask him/her to support plural forms, if for some reasons this can't be done, we can use "من" as in "وصل ثلاثة من الرجال" . (Thank you Munzir for the idea).
 
   
What can we do?
 
- Comment on this
 
- Mark all strings that contain plural forms as fuzzy, and replace the formula
 
in all files with the help of a script. Correct these fuzzy strings to add
 
missing cases.
 
   
  +
msgid "1 Item"
  +
msgid_plural "%d Items"
  +
msgstr[0] "لا عناصر"
  +
msgstr[1] "عنصر واحد"
  +
msgstr[2] "عنصران"
  +
msgstr[3] "%d عناصر"
  +
msgstr[4] "%d عنصرا"
  +
msgstr[5] "%d عنصر"
   
   
  +
As for Mozilla:
* [1] http://perso.menara.ma/yollnet/pluralforms1.png
 
== Conclusion ==
 
The main problem why reading numbers from the left to the right is not implementable is that there are no grammatical rules concerning this case. School books and grammar books do only cover reading from the right to the left. We would appreciate any information or reference that supports or contradicts this suggestion.
 
   
  +
<pre>
== Credits ==
 
  +
msgid "1 Item"
Chahibi is working on this.
 
  +
msgid_plural "%d Items"
  +
msgstr[0] "عنصر واحد"
  +
msgstr[1] "عنصران"
  +
msgstr[2] "%d عناصر"
  +
msgstr[3] "%d عنصرا"
  +
msgstr[4] "%d عنصر"
  +
msgstr[5] "لا عناصر"
 
</pre>
   
  +
[[Category:Standardization]]
</div>
 
  +
[[Category:English]]

المراجعة الحالية بتاريخ 02:18، 26 يناير 2017

Arabic.png

هذه الصفحة موجودة بالعربية تحت عنوان صيغ المعدود

GNU Gettext is used by most free software as a localization framework, one of GNU Getext features is plural forms.

Plurals

We are using now a 6 forms plural formula:

  • First form: for 0
  • Second form: for 1
  • Third form: for 2
  • Fourth form: for numbers that end with a number between 3 and 10 (like: 103, 1405, 23409).
  • Fifth form: for numbers that end with a number between 11 and 99 (like: 1099, 278).
  • Sixth form: for numbers above 100 ending with 0, 1 or 2 (like: 100, 232, 3001)

For Mozilla products (Firefox, Thunderbird, Sunbird, Fennec), the case where n == 0 is shifted to become the last case (due to some backward compatibility with the older plural rule).

Plural formula

This is the plural formula used for the forms above:

nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5;


An exception for Mozilla products is:

nplurals=6; plural=n==0 ? 5 : n==1 ? 0 : n==2 ? 1 : n%100>=3 && n%100<=10 ? 2 : n%100>=11 ? 3 : 4;


Examples

msgid "1 Item"
msgid_plural "%d Items"
msgstr[0] "لا عناصر"
msgstr[1] "عنصر واحد"
msgstr[2] "عنصران"
msgstr[3] "%d عناصر"
msgstr[4] "%d عنصرا"
msgstr[5] "%d عنصر"


As for Mozilla:

 msgid "1 Item"
 msgid_plural "%d Items"
 msgstr[0] "عنصر واحد"
 msgstr[1] "عنصران"
 msgstr[2] "%d عناصر"
 msgstr[3] "%d عنصرا"
 msgstr[4] "%d عنصر"
 msgstr[5] "لا عناصر"