Changeset View
Standalone View
src/core/loader.cpp
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Line(s) | 226 | if (minusPos != -1) { | |||
---|---|---|---|---|---|
239 | } | 239 | } | ||
240 | 240 | | |||
241 | localizedVariant = tr(variantEnglish.constData(), "dictionary variant"); | 241 | localizedVariant = tr(variantEnglish.constData(), "dictionary variant"); | ||
242 | isoCode = currentDictionary.left(minusPos); | 242 | isoCode = currentDictionary.left(minusPos); | ||
243 | } else { | 243 | } else { | ||
244 | isoCode = currentDictionary; | 244 | isoCode = currentDictionary; | ||
245 | } | 245 | } | ||
246 | 246 | | |||
247 | //These iso codes are missing in QLocale | ||||
248 | QMap<QString, QPair<QString, QString> > missingLocales = { | ||||
249 | //iso code //lang //country //English name of language | ||||
250 | {QLatin1String("an"), {QStringLiteral("aragonés"), QString()}}, //Aragonese | ||||
251 | {QLatin1String("an_ES"), {QStringLiteral("aragonés"), QStringLiteral("España")}}, | ||||
252 | {QLatin1String("csb"), {QStringLiteral("kaszëbsczi"), QString()}}, //Kashubian | ||||
253 | {QLatin1String("csb_PL"), {QStringLiteral("kaszëbsczi"), QStringLiteral("Polska")}}, | ||||
254 | {QLatin1String("cv"), {QStringLiteral("Чӑвашла"), QString()}}, //Chuvash | ||||
255 | {QLatin1String("cv_RU"), {QStringLiteral("Чӑвашла"), QStringLiteral("Россия")}}, | ||||
yurchor: This should be "Россия" (without the accent). | |||||
Is there any rule behind your decision to spell some language names capitalized and some others not capitalized? Examples:
I didn't find any indication that these languages might have a rule to capitalize language names like English has. aspotashev: Is there any rule behind your decision to spell some language names capitalized and some others… | |||||
I used wikipedia and the description files provided with the dictionaries for this information. It may not be correct however. If you know the language or the rules, please feel free to correct me and I will amend the commit accordingly waqar: I used wikipedia and the description files provided with the dictionaries for this information. | |||||
There may be different consistent approaches to capitalization:
I don't know which of these approaches is taken by Qt, but we should follow the pattern. Until then, I can't say how to fix this patch. After having a look on the Qt source code (qlocale_unix.cpp, qlocale_win.cpp) I'm not sure where do these native language names from on Unix/Linux. QSystemLocale::query() as defined in qlocale_unix.cpp seems to returns an empty QVariant. I think it would be really helpful if we add unit tests for this Loader::languageNameForCode() method. I don't know these languages, however I can read Russian and at least detect capital letters in languages that mostly reuse the Russian alphabet. Now so sure about Chuvash language anymore because English Wikipedia says "Чӑвашла" while Russian aspotashev: There may be different consistent approaches to capitalization:
# Use the spelling like if… | |||||
QLocale::nativeCountryName() QLocale::nativeLanguageName() Examples for cyrillic based using these two methods:
The language names are coming from qgetenv() I believe. It returns empty in case there was no language name found. In that case, Sonnet just returns the 'isoCode' e.g cv_RU. Great idea about the languageNameForCode() test. I will go ahead and write it. What should be the name for this test? waqar: ```
QLocale::nativeCountryName()
QLocale::nativeLanguageName()
```
Examples for cyrillic based… | |||||
256 | {QLatin1String("grc"), {QStringLiteral("Αρχαία Ελληνικά"), QString()}}, //Ancient Greek | ||||
257 | {QLatin1String("grc_GR"), {QStringLiteral("Αρχαία Ελληνικά"), QStringLiteral("Ελλάδα")}}, | ||||
258 | {QLatin1String("gug"), {QStringLiteral("Guarani"), QString()}}, //Gurarani | ||||
259 | {QLatin1String("gug_PY"), {QStringLiteral("Guarani"), QStringLiteral("Paraguái")}}, | ||||
260 | {QLatin1String("koi"), {QStringLiteral("коми"), QString()}}, //Komi | ||||
261 | {QLatin1String("koi_RU"), {QStringLiteral("коми"), QStringLiteral("Россия")}}, | ||||
yurchor: Same here | |||||
262 | {QLatin1String("lb"), {QStringLiteral("Lëtzebuergesch"), QString()}}, //Luxembourgish | ||||
263 | {QLatin1String("lb_LU"), {QStringLiteral("Lëtzebuergesch"), QStringLiteral("Lëtzebuerg")}}, | ||||
264 | {QLatin1String("ltg"), {QStringLiteral("latgalīšu"), QString()}}, //Latgalian | ||||
265 | {QLatin1String("ltz"), {QStringLiteral("Lëtzebuergesch"), QString()}}, //Luxembourgish | ||||
266 | {QLatin1String("ltz_LU"), {QStringLiteral("Lëtzebuergesch"), QStringLiteral("Lëtzebuerg")}}, | ||||
267 | {QLatin1String("nds"), {QStringLiteral("Plattdüütsch"), QString()}}, //Low German / Low Saxon | ||||
268 | {QLatin1String("pap"), {QStringLiteral("Papiamentu"), QString()}}, //Papiamentu | ||||
269 | {QLatin1String("pap_CW"), {QStringLiteral("Papiamentu"), QStringLiteral("Kòrsou")}}, | ||||
270 | {QLatin1String("vec"), {QStringLiteral("vèneto"), QString()}}, //Venetian | ||||
271 | {QLatin1String("vec_IT"), {QStringLiteral("vèneto"), QStringLiteral("Italia")}}, | ||||
272 | {QLatin1String("udm"), {QStringLiteral("удмурт"), QString()}}, //Udmurt | ||||
273 | {QLatin1String("udm_RU"), {QStringLiteral("удмурт"), QStringLiteral("Россия")}}, | ||||
yurchor: Same here | |||||
274 | }; | ||||
275 | | ||||
247 | QLocale locale(isoCode); | 276 | QLocale locale(isoCode); | ||
248 | localizedCountry = locale.nativeCountryName(); | 277 | localizedCountry = locale.nativeCountryName(); | ||
249 | localizedLang = locale.nativeLanguageName(); | 278 | localizedLang = locale.nativeLanguageName(); | ||
250 | 279 | | |||
280 | //QLocale didn't have this iso code, try to find in the missingLocales table | ||||
281 | if (localizedLang.isEmpty() && localizedCountry.isEmpty()) { | ||||
282 | localizedLang = missingLocales.value(isoCode).first; | ||||
283 | if (isoCode.length() > 3) { | ||||
284 | localizedCountry = missingLocales.value(isoCode).second; | ||||
285 | } | ||||
286 | | ||||
287 | //still empty, so just return the iso code | ||||
251 | if (localizedLang.isEmpty() && localizedCountry.isEmpty()) { | 288 | if (localizedLang.isEmpty() && localizedCountry.isEmpty()) { | ||
252 | return isoCode; // We have nothing | 289 | return isoCode; | ||
290 | } | ||||
253 | } | 291 | } | ||
254 | 292 | | |||
255 | if (!localizedCountry.isEmpty() && !localizedVariant.isEmpty()) { // We have both a country name and a variant | 293 | if (!localizedCountry.isEmpty() && !localizedVariant.isEmpty()) { // We have both a country name and a variant | ||
256 | return tr("%1 (%2) [%3]", "dictionary name; %1 = language name, %2 = country name and %3 = language variant name" | 294 | return tr("%1 (%2) [%3]", "dictionary name; %1 = language name, %2 = country name and %3 = language variant name" | ||
257 | ).arg(localizedLang, localizedCountry, localizedVariant); | 295 | ).arg(localizedLang, localizedCountry, localizedVariant); | ||
258 | } else if (!localizedCountry.isEmpty()) { // We have a country name | 296 | } else if (!localizedCountry.isEmpty()) { // We have a country name | ||
259 | return tr("%1 (%2)", "dictionary name; %1 = language name, %2 = country name" | 297 | return tr("%1 (%2)", "dictionary name; %1 = language name, %2 = country name" | ||
260 | ).arg(localizedLang, localizedCountry); | 298 | ).arg(localizedLang, localizedCountry); | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
This should be "Россия" (without the accent).