summaryrefslogtreecommitdiffstats
path: root/tools/linguist/shared/numerus.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-31 10:54:38 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-03-31 16:37:14 (GMT)
commit81c35b4d95a0da4d2b104aa84ba5de93d0d94d1d (patch)
tree0d350a5b96a50bb0c4c24265193c13492029a26a /tools/linguist/shared/numerus.cpp
parent1999331085a56242372c42f1dadfeeb0281e3f82 (diff)
downloadQt-81c35b4d95a0da4d2b104aa84ba5de93d0d94d1d.zip
Qt-81c35b4d95a0da4d2b104aa84ba5de93d0d94d1d.tar.gz
Qt-81c35b4d95a0da4d2b104aa84ba5de93d0d94d1d.tar.bz2
add Plural-Forms header in PO writer
Diffstat (limited to 'tools/linguist/shared/numerus.cpp')
-rw-r--r--tools/linguist/shared/numerus.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/tools/linguist/shared/numerus.cpp b/tools/linguist/shared/numerus.cpp
index 287dd03..c002119 100644
--- a/tools/linguist/shared/numerus.cpp
+++ b/tools/linguist/shared/numerus.cpp
@@ -318,28 +318,45 @@ struct NumerusTableEntry {
const char * const *forms;
const QLocale::Language *languages;
const QLocale::Country *countries;
+ const char * const gettextRules;
};
static const NumerusTableEntry numerusTable[] = {
- { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0 },
- { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0 },
+ { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0, "nplurals=1; plural=0;" },
+ { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0,
+ "nplurals=2; plural=(n != 1);" },
{ frenchStyleRules, sizeof(frenchStyleRules), frenchStyleForms, frenchStyleLanguages,
- frenchStyleCountries },
- { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0 },
- { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0 },
- { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0 },
- { slovakRules, sizeof(slovakRules), slovakForms, slovakLanguages, 0 },
- { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0 },
- { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0 },
- { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0 },
- { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0 },
- { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0 },
- { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0 },
- { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0 },
- { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0 },
- { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0 },
- { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0 },
- { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0 }
+ frenchStyleCountries, "nplurals=2; plural=(n > 1);" },
+ { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" },
+ { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0,
+ "nplurals=2; plural=(n%10==1 && n%100!=11 ? 0 : 1);" },
+ { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0,
+ "nplurals=3; plural=(n==1 ? 0 : n==2 ? 1 : 2);" },
+ { slovakRules, sizeof(slovakRules), slovakForms, slovakLanguages, 0,
+ "nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);" },
+ { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0,
+ "nplurals=3; plural=(n%100==1 ? 0 : n%100==2 ? 1 : 2);" },
+ { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0,
+ "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
+ { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);" },
+ { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0,
+ "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);" },
+ { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0,
+ "nplurals=4; plural=(n==1 ? 0 : (n==0 || (n%100>=1 && n%100<=10)) ? 1 : (n%100>=11 && n%100<=19) ? 2 : 3);" },
+ { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0,
+ "nplurals=5; plural=(n==0 ? 0 : n==1 ? 1 : (n>=2 && n<=5) ? 2 : n==6 ? 3 : 4);" },
+ { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0,
+ "nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : (n%100>=3 && n%100<=10) ? 3 : n%100>=11 ? 4 : 5);" },
+ { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n%10==4 || n%10==6 || n%10== 9) ? 1 : 2);" },
+ { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0,
+ "nplurals=3; plural=(n==1 ? 0 : (n==11 || n/1000==11 || n/1000000==11 || n/1000000000==11) ? 1 : 2);" },
};
static const int NumerusTableSize = sizeof(numerusTable) / sizeof(numerusTable[0]);
@@ -352,7 +369,7 @@ static const uchar magic[MagicLength] = {
};
bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
- QByteArray *rules, QStringList *forms)
+ QByteArray *rules, QStringList *forms, const char **gettextRules)
{
while (true) {
for (int i = 0; i < NumerusTableSize; ++i) {
@@ -365,6 +382,8 @@ bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
*rules = QByteArray::fromRawData(reinterpret_cast<const char *>(entry.rules),
entry.rulesSize);
}
+ if (gettextRules)
+ *gettextRules = entry.gettextRules;
if (forms) {
forms->clear();
for (int k = 0; entry.forms[k]; ++k)