[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the Qt Linguist of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "translator.h"
|
---|
| 43 |
|
---|
| 44 | #include <QtCore/QByteArray>
|
---|
| 45 | #include <QtCore/QDebug>
|
---|
| 46 | #include <QtCore/QDir>
|
---|
| 47 | #include <QtCore/QFile>
|
---|
| 48 | #include <QtCore/QFileInfo>
|
---|
| 49 | #include <QtCore/QMap>
|
---|
| 50 |
|
---|
| 51 | #include <private/qtranslator_p.h>
|
---|
| 52 |
|
---|
| 53 | QT_BEGIN_NAMESPACE
|
---|
| 54 |
|
---|
| 55 | static const uchar englishStyleRules[] =
|
---|
| 56 | { Q_EQ, 1 };
|
---|
| 57 | static const uchar frenchStyleRules[] =
|
---|
| 58 | { Q_LEQ, 1 };
|
---|
| 59 | static const uchar latvianRules[] =
|
---|
| 60 | { Q_MOD_10 | Q_EQ, 1, Q_AND, Q_MOD_100 | Q_NEQ, 11, Q_NEWRULE,
|
---|
| 61 | Q_NEQ, 0 };
|
---|
[561] | 62 | static const uchar icelandicRules[] =
|
---|
| 63 | { Q_MOD_10 | Q_EQ, 1, Q_AND, Q_MOD_100 | Q_NEQ, 11 };
|
---|
[2] | 64 | static const uchar irishStyleRules[] =
|
---|
| 65 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 66 | Q_EQ, 2 };
|
---|
[846] | 67 | static const uchar slovakStyleRules[] =
|
---|
[2] | 68 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 69 | Q_BETWEEN, 2, 4 };
|
---|
| 70 | static const uchar macedonianRules[] =
|
---|
| 71 | { Q_MOD_10 | Q_EQ, 1, Q_NEWRULE,
|
---|
| 72 | Q_MOD_10 | Q_EQ, 2 };
|
---|
| 73 | static const uchar lithuanianRules[] =
|
---|
| 74 | { Q_MOD_10 | Q_EQ, 1, Q_AND, Q_MOD_100 | Q_NEQ, 11, Q_NEWRULE,
|
---|
[561] | 75 | Q_MOD_10 | Q_NEQ, 0, Q_AND, Q_MOD_100 | Q_NOT_BETWEEN, 10, 19 };
|
---|
[2] | 76 | static const uchar russianStyleRules[] =
|
---|
| 77 | { Q_MOD_10 | Q_EQ, 1, Q_AND, Q_MOD_100 | Q_NEQ, 11, Q_NEWRULE,
|
---|
| 78 | Q_MOD_10 | Q_BETWEEN, 2, 4, Q_AND, Q_MOD_100 | Q_NOT_BETWEEN, 10, 19 };
|
---|
| 79 | static const uchar polishRules[] =
|
---|
| 80 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 81 | Q_MOD_10 | Q_BETWEEN, 2, 4, Q_AND, Q_MOD_100 | Q_NOT_BETWEEN, 10, 19 };
|
---|
| 82 | static const uchar romanianRules[] =
|
---|
| 83 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 84 | Q_EQ, 0, Q_OR, Q_MOD_100 | Q_BETWEEN, 1, 19 };
|
---|
| 85 | static const uchar slovenianRules[] =
|
---|
| 86 | { Q_MOD_100 | Q_EQ, 1, Q_NEWRULE,
|
---|
| 87 | Q_MOD_100 | Q_EQ, 2, Q_NEWRULE,
|
---|
| 88 | Q_MOD_100 | Q_BETWEEN, 3, 4 };
|
---|
| 89 | static const uchar malteseRules[] =
|
---|
| 90 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 91 | Q_EQ, 0, Q_OR, Q_MOD_100 | Q_BETWEEN, 1, 10, Q_NEWRULE,
|
---|
| 92 | Q_MOD_100 | Q_BETWEEN, 11, 19 };
|
---|
| 93 | static const uchar welshRules[] =
|
---|
| 94 | { Q_EQ, 0, Q_NEWRULE,
|
---|
| 95 | Q_EQ, 1, Q_NEWRULE,
|
---|
| 96 | Q_BETWEEN, 2, 5, Q_NEWRULE,
|
---|
| 97 | Q_EQ, 6 };
|
---|
| 98 | static const uchar arabicRules[] =
|
---|
| 99 | { Q_EQ, 0, Q_NEWRULE,
|
---|
| 100 | Q_EQ, 1, Q_NEWRULE,
|
---|
| 101 | Q_EQ, 2, Q_NEWRULE,
|
---|
| 102 | Q_MOD_100 | Q_BETWEEN, 3, 10, Q_NEWRULE,
|
---|
[846] | 103 | Q_MOD_100 | Q_GEQ, 11 };
|
---|
[561] | 104 | static const uchar tagalogRules[] =
|
---|
| 105 | { Q_LEQ, 1, Q_NEWRULE,
|
---|
| 106 | Q_MOD_10 | Q_EQ, 4, Q_OR, Q_MOD_10 | Q_EQ, 6, Q_OR, Q_MOD_10 | Q_EQ, 9 };
|
---|
| 107 | static const uchar catalanRules[] =
|
---|
| 108 | { Q_EQ, 1, Q_NEWRULE,
|
---|
| 109 | Q_LEAD_1000 | Q_EQ, 11 };
|
---|
[2] | 110 |
|
---|
| 111 | static const char * const japaneseStyleForms[] = { "Universal Form", 0 };
|
---|
| 112 | static const char * const englishStyleForms[] = { "Singular", "Plural", 0 };
|
---|
| 113 | static const char * const frenchStyleForms[] = { "Singular", "Plural", 0 };
|
---|
[561] | 114 | static const char * const icelandicForms[] = { "Singular", "Plural", 0 };
|
---|
[2] | 115 | static const char * const latvianForms[] = { "Singular", "Plural", "Nullar", 0 };
|
---|
| 116 | static const char * const irishStyleForms[] = { "Singular", "Dual", "Plural", 0 };
|
---|
[846] | 117 | static const char * const slovakStyleForms[] = { "Singular", "Paucal", "Plural", 0 };
|
---|
[2] | 118 | static const char * const macedonianForms[] = { "Singular", "Dual", "Plural", 0 };
|
---|
[561] | 119 | static const char * const lithuanianForms[] = { "Singular", "Paucal", "Plural", 0 };
|
---|
[2] | 120 | static const char * const russianStyleForms[] = { "Singular", "Dual", "Plural", 0 };
|
---|
| 121 | static const char * const polishForms[] = { "Singular", "Paucal", "Plural", 0 };
|
---|
[561] | 122 | static const char * const romanianForms[] = { "Singular", "Paucal", "Plural", 0 };
|
---|
[2] | 123 | static const char * const slovenianForms[] = { "Singular", "Dual", "Trial", "Plural", 0 };
|
---|
| 124 | static const char * const malteseForms[] =
|
---|
[561] | 125 | { "Singular", "Paucal", "Greater Paucal", "Plural", 0 };
|
---|
[2] | 126 | static const char * const welshForms[] =
|
---|
| 127 | { "Nullar", "Singular", "Dual", "Sexal", "Plural", 0 };
|
---|
| 128 | static const char * const arabicForms[] =
|
---|
[561] | 129 | { "Nullar", "Singular", "Dual", "Minority Plural", "Plural", "Plural (100-102, ...)", 0 };
|
---|
| 130 | static const char * const tagalogForms[] =
|
---|
| 131 | { "Singular", "Plural (consonant-ended)", "Plural (vowel-ended)", 0 };
|
---|
| 132 | static const char * const catalanForms[] = { "Singular", "Undecal (11)", "Plural", 0 };
|
---|
[2] | 133 |
|
---|
| 134 | #define EOL QLocale::C
|
---|
| 135 |
|
---|
| 136 | static const QLocale::Language japaneseStyleLanguages[] = {
|
---|
| 137 | QLocale::Afan,
|
---|
| 138 | QLocale::Armenian,
|
---|
| 139 | QLocale::Bhutani,
|
---|
| 140 | QLocale::Bislama,
|
---|
| 141 | QLocale::Burmese,
|
---|
| 142 | QLocale::Chinese,
|
---|
| 143 | QLocale::FijiLanguage,
|
---|
| 144 | QLocale::Guarani,
|
---|
| 145 | QLocale::Hungarian,
|
---|
| 146 | QLocale::Indonesian,
|
---|
| 147 | QLocale::Japanese,
|
---|
| 148 | QLocale::Javanese,
|
---|
| 149 | QLocale::Korean,
|
---|
| 150 | QLocale::Malay,
|
---|
| 151 | QLocale::NauruLanguage,
|
---|
| 152 | QLocale::Persian,
|
---|
| 153 | QLocale::Sundanese,
|
---|
| 154 | QLocale::Thai,
|
---|
| 155 | QLocale::Tibetan,
|
---|
[561] | 156 | QLocale::Turkish,
|
---|
[2] | 157 | QLocale::Vietnamese,
|
---|
| 158 | QLocale::Yoruba,
|
---|
| 159 | QLocale::Zhuang,
|
---|
| 160 | EOL
|
---|
| 161 | };
|
---|
| 162 |
|
---|
| 163 | static const QLocale::Language englishStyleLanguages[] = {
|
---|
| 164 | QLocale::Abkhazian,
|
---|
| 165 | QLocale::Afar,
|
---|
| 166 | QLocale::Afrikaans,
|
---|
| 167 | QLocale::Albanian,
|
---|
| 168 | QLocale::Amharic,
|
---|
| 169 | QLocale::Assamese,
|
---|
| 170 | QLocale::Aymara,
|
---|
| 171 | QLocale::Azerbaijani,
|
---|
| 172 | QLocale::Bashkir,
|
---|
| 173 | QLocale::Basque,
|
---|
| 174 | QLocale::Bengali,
|
---|
| 175 | QLocale::Bihari,
|
---|
| 176 | // Missing: Bokmal,
|
---|
| 177 | QLocale::Bulgarian,
|
---|
| 178 | QLocale::Cambodian,
|
---|
| 179 | QLocale::Cornish,
|
---|
| 180 | QLocale::Corsican,
|
---|
| 181 | QLocale::Danish,
|
---|
| 182 | QLocale::Dutch,
|
---|
| 183 | QLocale::English,
|
---|
| 184 | QLocale::Esperanto,
|
---|
| 185 | QLocale::Estonian,
|
---|
| 186 | QLocale::Faroese,
|
---|
| 187 | QLocale::Finnish,
|
---|
| 188 | // Missing: Friulian,
|
---|
| 189 | QLocale::Frisian,
|
---|
| 190 | QLocale::Galician,
|
---|
| 191 | QLocale::Georgian,
|
---|
| 192 | QLocale::German,
|
---|
| 193 | QLocale::Greek,
|
---|
| 194 | QLocale::Greenlandic,
|
---|
| 195 | QLocale::Gujarati,
|
---|
| 196 | QLocale::Hausa,
|
---|
| 197 | QLocale::Hebrew,
|
---|
| 198 | QLocale::Hindi,
|
---|
| 199 | QLocale::Interlingua,
|
---|
| 200 | QLocale::Interlingue,
|
---|
| 201 | QLocale::Italian,
|
---|
| 202 | QLocale::Kannada,
|
---|
| 203 | QLocale::Kashmiri,
|
---|
| 204 | QLocale::Kazakh,
|
---|
| 205 | QLocale::Kinyarwanda,
|
---|
| 206 | QLocale::Kirghiz,
|
---|
| 207 | QLocale::Kurdish,
|
---|
| 208 | QLocale::Kurundi,
|
---|
| 209 | QLocale::Laothian,
|
---|
| 210 | QLocale::Latin,
|
---|
| 211 | // Missing: Letzeburgesch,
|
---|
| 212 | QLocale::Lingala,
|
---|
| 213 | QLocale::Malagasy,
|
---|
| 214 | QLocale::Malayalam,
|
---|
| 215 | QLocale::Marathi,
|
---|
| 216 | QLocale::Mongolian,
|
---|
| 217 | // Missing: Nahuatl,
|
---|
| 218 | QLocale::Nepali,
|
---|
| 219 | // Missing: Northern Sotho,
|
---|
| 220 | QLocale::Norwegian,
|
---|
| 221 | QLocale::Nynorsk,
|
---|
| 222 | QLocale::Occitan,
|
---|
| 223 | QLocale::Oriya,
|
---|
| 224 | QLocale::Pashto,
|
---|
| 225 | QLocale::Portuguese,
|
---|
| 226 | QLocale::Punjabi,
|
---|
| 227 | QLocale::Quechua,
|
---|
| 228 | QLocale::RhaetoRomance,
|
---|
| 229 | QLocale::Sesotho,
|
---|
| 230 | QLocale::Setswana,
|
---|
| 231 | QLocale::Shona,
|
---|
| 232 | QLocale::Sindhi,
|
---|
| 233 | QLocale::Singhalese,
|
---|
| 234 | QLocale::Siswati,
|
---|
| 235 | QLocale::Somali,
|
---|
| 236 | QLocale::Spanish,
|
---|
| 237 | QLocale::Swahili,
|
---|
| 238 | QLocale::Swedish,
|
---|
| 239 | QLocale::Tajik,
|
---|
| 240 | QLocale::Tamil,
|
---|
| 241 | QLocale::Tatar,
|
---|
| 242 | QLocale::Telugu,
|
---|
| 243 | QLocale::TongaLanguage,
|
---|
| 244 | QLocale::Tsonga,
|
---|
| 245 | QLocale::Turkmen,
|
---|
| 246 | QLocale::Twi,
|
---|
| 247 | QLocale::Uigur,
|
---|
[561] | 248 | QLocale::Urdu,
|
---|
[2] | 249 | QLocale::Uzbek,
|
---|
| 250 | QLocale::Volapuk,
|
---|
| 251 | QLocale::Wolof,
|
---|
| 252 | QLocale::Xhosa,
|
---|
| 253 | QLocale::Yiddish,
|
---|
| 254 | QLocale::Zulu,
|
---|
| 255 | EOL
|
---|
| 256 | };
|
---|
| 257 | static const QLocale::Language frenchStyleLanguages[] = {
|
---|
| 258 | // keep synchronized with frenchStyleCountries
|
---|
| 259 | QLocale::Breton,
|
---|
| 260 | QLocale::French,
|
---|
| 261 | QLocale::Portuguese,
|
---|
| 262 | // Missing: Filipino,
|
---|
| 263 | QLocale::Tigrinya,
|
---|
| 264 | // Missing: Walloon
|
---|
| 265 | EOL
|
---|
| 266 | };
|
---|
| 267 | static const QLocale::Language latvianLanguage[] = { QLocale::Latvian, EOL };
|
---|
[561] | 268 | static const QLocale::Language icelandicLanguage[] = { QLocale::Icelandic, EOL };
|
---|
[2] | 269 | static const QLocale::Language irishStyleLanguages[] = {
|
---|
| 270 | QLocale::Divehi,
|
---|
| 271 | QLocale::Gaelic,
|
---|
| 272 | QLocale::Inuktitut,
|
---|
| 273 | QLocale::Inupiak,
|
---|
| 274 | QLocale::Irish,
|
---|
| 275 | QLocale::Manx,
|
---|
| 276 | QLocale::Maori,
|
---|
| 277 | // Missing: Sami,
|
---|
| 278 | QLocale::Samoan,
|
---|
| 279 | QLocale::Sanskrit,
|
---|
| 280 | EOL
|
---|
| 281 | };
|
---|
[846] | 282 | static const QLocale::Language slovakStyleLanguages[] = { QLocale::Slovak, QLocale::Czech, EOL };
|
---|
[2] | 283 | static const QLocale::Language macedonianLanguage[] = { QLocale::Macedonian, EOL };
|
---|
| 284 | static const QLocale::Language lithuanianLanguage[] = { QLocale::Lithuanian, EOL };
|
---|
| 285 | static const QLocale::Language russianStyleLanguages[] = {
|
---|
| 286 | QLocale::Bosnian,
|
---|
| 287 | QLocale::Byelorussian,
|
---|
| 288 | QLocale::Croatian,
|
---|
| 289 | QLocale::Russian,
|
---|
| 290 | QLocale::Serbian,
|
---|
| 291 | QLocale::SerboCroatian,
|
---|
| 292 | QLocale::Ukrainian,
|
---|
| 293 | EOL
|
---|
| 294 | };
|
---|
| 295 | static const QLocale::Language polishLanguage[] = { QLocale::Polish, EOL };
|
---|
| 296 | static const QLocale::Language romanianLanguages[] = {
|
---|
| 297 | QLocale::Moldavian,
|
---|
| 298 | QLocale::Romanian,
|
---|
| 299 | EOL
|
---|
| 300 | };
|
---|
| 301 | static const QLocale::Language slovenianLanguage[] = { QLocale::Slovenian, EOL };
|
---|
| 302 | static const QLocale::Language malteseLanguage[] = { QLocale::Maltese, EOL };
|
---|
| 303 | static const QLocale::Language welshLanguage[] = { QLocale::Welsh, EOL };
|
---|
| 304 | static const QLocale::Language arabicLanguage[] = { QLocale::Arabic, EOL };
|
---|
[561] | 305 | static const QLocale::Language tagalogLanguage[] = { QLocale::Tagalog, EOL };
|
---|
| 306 | static const QLocale::Language catalanLanguage[] = { QLocale::Catalan, EOL };
|
---|
[2] | 307 |
|
---|
| 308 | static const QLocale::Country frenchStyleCountries[] = {
|
---|
| 309 | // keep synchronized with frenchStyleLanguages
|
---|
| 310 | QLocale::AnyCountry,
|
---|
| 311 | QLocale::AnyCountry,
|
---|
| 312 | QLocale::Brazil,
|
---|
| 313 | QLocale::AnyCountry
|
---|
| 314 | };
|
---|
| 315 | struct NumerusTableEntry {
|
---|
| 316 | const uchar *rules;
|
---|
| 317 | int rulesSize;
|
---|
| 318 | const char * const *forms;
|
---|
| 319 | const QLocale::Language *languages;
|
---|
| 320 | const QLocale::Country *countries;
|
---|
[846] | 321 | const char * const gettextRules;
|
---|
[2] | 322 | };
|
---|
| 323 |
|
---|
| 324 | static const NumerusTableEntry numerusTable[] = {
|
---|
[846] | 325 | { 0, 0, japaneseStyleForms, japaneseStyleLanguages, 0, "nplurals=1; plural=0;" },
|
---|
| 326 | { englishStyleRules, sizeof(englishStyleRules), englishStyleForms, englishStyleLanguages, 0,
|
---|
| 327 | "nplurals=2; plural=(n != 1);" },
|
---|
[2] | 328 | { frenchStyleRules, sizeof(frenchStyleRules), frenchStyleForms, frenchStyleLanguages,
|
---|
[846] | 329 | frenchStyleCountries, "nplurals=2; plural=(n > 1);" },
|
---|
| 330 | { latvianRules, sizeof(latvianRules), latvianForms, latvianLanguage, 0,
|
---|
| 331 | "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);" },
|
---|
| 332 | { icelandicRules, sizeof(icelandicRules), icelandicForms, icelandicLanguage, 0,
|
---|
| 333 | "nplurals=2; plural=(n%10==1 && n%100!=11 ? 0 : 1);" },
|
---|
| 334 | { irishStyleRules, sizeof(irishStyleRules), irishStyleForms, irishStyleLanguages, 0,
|
---|
| 335 | "nplurals=3; plural=(n==1 ? 0 : n==2 ? 1 : 2);" },
|
---|
| 336 | { slovakStyleRules, sizeof(slovakStyleRules), slovakStyleForms, slovakStyleLanguages, 0,
|
---|
| 337 | "nplurals=3; plural=((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2);" },
|
---|
| 338 | { macedonianRules, sizeof(macedonianRules), macedonianForms, macedonianLanguage, 0,
|
---|
| 339 | "nplurals=3; plural=(n%100==1 ? 0 : n%100==2 ? 1 : 2);" },
|
---|
| 340 | { lithuanianRules, sizeof(lithuanianRules), lithuanianForms, lithuanianLanguage, 0,
|
---|
| 341 | "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);" },
|
---|
| 342 | { russianStyleRules, sizeof(russianStyleRules), russianStyleForms, russianStyleLanguages, 0,
|
---|
| 343 | "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
|
---|
| 344 | { polishRules, sizeof(polishRules), polishForms, polishLanguage, 0,
|
---|
| 345 | "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);" },
|
---|
| 346 | { romanianRules, sizeof(romanianRules), romanianForms, romanianLanguages, 0,
|
---|
| 347 | "nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2);" },
|
---|
| 348 | { slovenianRules, sizeof(slovenianRules), slovenianForms, slovenianLanguage, 0,
|
---|
| 349 | "nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);" },
|
---|
| 350 | { malteseRules, sizeof(malteseRules), malteseForms, malteseLanguage, 0,
|
---|
| 351 | "nplurals=4; plural=(n==1 ? 0 : (n==0 || (n%100>=1 && n%100<=10)) ? 1 : (n%100>=11 && n%100<=19) ? 2 : 3);" },
|
---|
| 352 | { welshRules, sizeof(welshRules), welshForms, welshLanguage, 0,
|
---|
| 353 | "nplurals=5; plural=(n==0 ? 0 : n==1 ? 1 : (n>=2 && n<=5) ? 2 : n==6 ? 3 : 4);" },
|
---|
| 354 | { arabicRules, sizeof(arabicRules), arabicForms, arabicLanguage, 0,
|
---|
| 355 | "nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : (n%100>=3 && n%100<=10) ? 3 : n%100>=11 ? 4 : 5);" },
|
---|
| 356 | { tagalogRules, sizeof(tagalogRules), tagalogForms, tagalogLanguage, 0,
|
---|
| 357 | "nplurals=3; plural=(n==1 ? 0 : (n%10==4 || n%10==6 || n%10== 9) ? 1 : 2);" },
|
---|
| 358 | { catalanRules, sizeof(catalanRules), catalanForms, catalanLanguage, 0,
|
---|
| 359 | "nplurals=3; plural=(n==1 ? 0 : (n==11 || n/1000==11 || n/1000000==11 || n/1000000000==11) ? 1 : 2);" },
|
---|
[2] | 360 | };
|
---|
| 361 |
|
---|
| 362 | static const int NumerusTableSize = sizeof(numerusTable) / sizeof(numerusTable[0]);
|
---|
| 363 |
|
---|
| 364 | // magic number for the file
|
---|
| 365 | static const int MagicLength = 16;
|
---|
| 366 | static const uchar magic[MagicLength] = {
|
---|
| 367 | 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95,
|
---|
| 368 | 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd
|
---|
| 369 | };
|
---|
| 370 |
|
---|
| 371 | bool getNumerusInfo(QLocale::Language language, QLocale::Country country,
|
---|
[846] | 372 | QByteArray *rules, QStringList *forms, const char **gettextRules)
|
---|
[2] | 373 | {
|
---|
| 374 | while (true) {
|
---|
| 375 | for (int i = 0; i < NumerusTableSize; ++i) {
|
---|
| 376 | const NumerusTableEntry &entry = numerusTable[i];
|
---|
| 377 | for (int j = 0; entry.languages[j] != EOL; ++j) {
|
---|
| 378 | if (entry.languages[j] == language
|
---|
| 379 | && ((!entry.countries && country == QLocale::AnyCountry)
|
---|
| 380 | || (entry.countries && entry.countries[j] == country))) {
|
---|
| 381 | if (rules) {
|
---|
| 382 | *rules = QByteArray::fromRawData(reinterpret_cast<const char *>(entry.rules),
|
---|
| 383 | entry.rulesSize);
|
---|
| 384 | }
|
---|
[846] | 385 | if (gettextRules)
|
---|
| 386 | *gettextRules = entry.gettextRules;
|
---|
[2] | 387 | if (forms) {
|
---|
| 388 | forms->clear();
|
---|
| 389 | for (int k = 0; entry.forms[k]; ++k)
|
---|
| 390 | forms->append(QLatin1String(entry.forms[k]));
|
---|
| 391 | }
|
---|
| 392 | return true;
|
---|
| 393 | }
|
---|
| 394 | }
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | if (country == QLocale::AnyCountry)
|
---|
| 398 | break;
|
---|
| 399 | country = QLocale::AnyCountry;
|
---|
| 400 | }
|
---|
| 401 | return false;
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | QT_END_NAMESPACE
|
---|