[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature: 1 plik, 2 pliki, 5 plikov
From: |
Joosep-Georg Järvemaa |
Subject: |
feature: 1 plik, 2 pliki, 5 plikov |
Date: |
Wed, 3 Apr 2002 19:38:42 +0300 (EEST) |
Hi!
I did read the documentation and discovered this "pliki" problem. The same
story goes also with Russian. But what about the following idea.
In Polish .po files use syntax like this:
# available forms
msgid "<index> %d files"
msgstr "all,all:1:1,last_digit:2:4"
# default case
msgid "<all> %d files"
msgstr "%d plikóv"
# exactly 1
msgid "<all:1:1> %d files"
msgstr "%d plik"
# last digit between 1 and 5 (not inclusive)
msgid "<last_digit:2:4> %d files"
msgstr "%d pliki"
and in English:
msgid "<index> %d files"
msgstr "all,all:1:1"
msgid "<all> %d files"
msgstr "%d files"
msgid "<all:1:1> %d files"
msgstr "%d file"
Now the application programmer (or even gettext itself) must before
outputting strings do something like that:
str_result = msgid;
if (msgid_contains_integer) {
str_available_forms = gettext("<index> " + msgid);
arr_available_forms = split(",", str_available_forms);
foreach (arr_available_forms as $str_condition) {
bool_match = TRUE;
arr_condition = split(":", str_condition);
str_algorithm = arr_condition[0];
int_start = arr_condition[1];
int_end = arr_condition[2];
switch (str_algorithm) {
case "last_digit":
int_number = int_number - 10 * intval(int_number / 10);
break;
case "all":
// same as default
default:
// leave the number untouched
}
if (! empty(int_start)) {
bool_match = int_number <= int_start;
}
if (! empty(int_end)) {
bool_match = bool_match && (int_number <= int_ent);
}
if (bool_match) {
str_result = gettext("<" + str_condition + "> " + msgid);
}
}
} else { // if (msgid_contains_integer)
str_result = gettext(msgid);
} // else : if (msgid_contains_integer)
This was, well, not in C ;) but hopefully understandable.
--
Joosep-Georg Järvemaa
Q: Do you know what the death rate around here is?
A: One per person.
- feature: 1 plik, 2 pliki, 5 plikov,
Joosep-Georg Järvemaa <=