mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix Hunspell spellchecking with Qt 6
This commit is contained in:
parent
3a9f34e47b
commit
9309f98094
1 changed files with 49 additions and 55 deletions
|
@ -40,29 +40,23 @@ constexpr auto kExceptions = {
|
|||
"\xd0\xa2\xd0\xb5\xd0\xbb\xd0\xb5\xd0\xb3\xd1\x80\xd0\xb0\xd0\xbc"_cs,
|
||||
};
|
||||
|
||||
// 31 - QLocale::English, 91 - QLocale::Portuguese.
|
||||
constexpr auto kLangsForLWC = { 31, 91 };
|
||||
// 225 - QLocale::UnitesStates, 30 - QLocale::Brazil.
|
||||
constexpr auto kDefaultCountries = { 225, 30 };
|
||||
constexpr auto kLangsForLWC = { QLocale::English, QLocale::Portuguese };
|
||||
constexpr auto kDefaultCountries = { QLocale::UnitedStates, QLocale::Brazil };
|
||||
|
||||
// Language With Country.
|
||||
inline auto LWC(QLocale::Country country) {
|
||||
const auto l = QLocale::matchingLocales(
|
||||
QLocale::AnyLanguage,
|
||||
QLocale::AnyScript,
|
||||
country)[0];
|
||||
inline auto LWC(QLocale::Language language, QLocale::Country country) {
|
||||
if (ranges::contains(kDefaultCountries, country)) {
|
||||
return int(l.language());
|
||||
return int(language);
|
||||
}
|
||||
return (l.language() * 1000) + country;
|
||||
return (language * 1000) + country;
|
||||
}
|
||||
|
||||
inline auto LanguageFromLocale(QLocale loc) {
|
||||
const auto locLang = int(loc.language());
|
||||
const auto locLang = loc.language();
|
||||
return (ranges::contains(kLangsForLWC, locLang)
|
||||
&& (loc.country() != QLocale::AnyCountry))
|
||||
? LWC(loc.country())
|
||||
: locLang;
|
||||
? LWC(locLang, loc.country())
|
||||
: int(locLang);
|
||||
}
|
||||
|
||||
const auto kDictionaries = {
|
||||
|
@ -74,9 +68,9 @@ const auto kDictionaries = {
|
|||
Dict{{ QLocale::Danish, 598, 345'874, "\x44\x61\x6e\x73\x6b" }}, // da_DK
|
||||
Dict{{ QLocale::German, 599, 2'412'780, "\x44\x65\x75\x74\x73\x63\x68" }}, // de_DE
|
||||
Dict{{ QLocale::Greek, 600, 1'389'160, "\xce\x95\xce\xbb\xce\xbb\xce\xb7\xce\xbd\xce\xb9\xce\xba\xce\xac" }}, // el_GR
|
||||
Dict{{ LWC(QLocale::Australia), 601, 175'266, "English (Australia)" }}, // en_AU
|
||||
Dict{{ LWC(QLocale::Canada), 602, 174'295, "English (Canada)" }}, // en_CA
|
||||
Dict{{ LWC(QLocale::UnitedKingdom), 603, 174'433, "English (United Kingdom)" }}, // en_GB
|
||||
Dict{{ LWC(QLocale::English, QLocale::Australia), 601, 175'266, "English (Australia)" }}, // en_AU
|
||||
Dict{{ LWC(QLocale::English, QLocale::Canada), 602, 174'295, "English (Canada)" }}, // en_CA
|
||||
Dict{{ LWC(QLocale::English, QLocale::UnitedKingdom), 603, 174'433, "English (United Kingdom)" }}, // en_GB
|
||||
Dict{{ QLocale::Spanish, 604, 264'717, "\x45\x73\x70\x61\xc3\xb1\x6f\x6c" }}, // es_ES
|
||||
Dict{{ QLocale::Estonian, 605, 757'394, "\x45\x65\x73\x74\x69" }}, // et_EE
|
||||
Dict{{ QLocale::Persian, 606, 333'911, "\xd9\x81\xd8\xa7\xd8\xb1\xd8\xb3\xdb\x8c" }}, // fa_IR
|
||||
|
@ -95,7 +89,7 @@ const auto kDictionaries = {
|
|||
Dict{{ QLocale::Dutch, 619, 743'406, "\x4e\x65\x64\x65\x72\x6c\x61\x6e\x64\x73" }}, // nl_NL
|
||||
Dict{{ QLocale::Polish, 620, 1'015'747, "\x50\x6f\x6c\x73\x6b\x69" }}, // pl_PL
|
||||
Dict{{ QLocale::Portuguese, 621, 1'231'999, "\x50\x6f\x72\x74\x75\x67\x75\xc3\xaa\x73 (Brazil)" }}, // pt_BR
|
||||
Dict{{ LWC(QLocale::Portugal), 622, 138'571, "\x50\x6f\x72\x74\x75\x67\x75\xc3\xaa\x73" }}, // pt_PT
|
||||
Dict{{ LWC(QLocale::Portuguese, QLocale::Portugal), 622, 138'571, "\x50\x6f\x72\x74\x75\x67\x75\xc3\xaa\x73" }}, // pt_PT
|
||||
Dict{{ QLocale::Romanian, 623, 455'643, "\x52\x6f\x6d\xc3\xa2\x6e\xc4\x83" }}, // ro_RO
|
||||
Dict{{ QLocale::Russian, 624, 463'194, "\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9" }}, // ru_RU
|
||||
Dict{{ QLocale::Slovak, 625, 525'328, "\x53\x6c\x6f\x76\x65\x6e\xc4\x8d\x69\x6e\x61" }}, // sk_SK
|
||||
|
|
Loading…
Add table
Reference in a new issue