mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
fix: pluralization
This commit is contained in:
@@ -20,6 +20,15 @@ std::map<QString, QString> langMapping = {
|
||||
{"zh-hant-raw", "zh-hant"},
|
||||
};
|
||||
|
||||
constexpr auto postfixes = {
|
||||
"zero",
|
||||
"one",
|
||||
"two",
|
||||
"few",
|
||||
"many",
|
||||
"other"
|
||||
};
|
||||
|
||||
AyuLanguage *AyuLanguage::instance = nullptr;
|
||||
|
||||
AyuLanguage::AyuLanguage() = default;
|
||||
@@ -109,14 +118,19 @@ void AyuLanguage::applyLanguageJson(QJsonDocument doc) {
|
||||
auto key = qsl("ayu_") + brokenKey;
|
||||
auto val = json.value(brokenKey).toString().replace(qsl("&"), qsl("&"));
|
||||
|
||||
if (key.endsWith("_zero") || key.endsWith("_two") || key.endsWith("_few") || key.endsWith("_many")) {
|
||||
if (key.endsWith("_Android")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key.endsWith("_one")) {
|
||||
key = key.replace("_one", "#one");
|
||||
} else if (key.endsWith("_other")) {
|
||||
key = key.replace("_other", "#other");
|
||||
for (const auto &postfix : postfixes) {
|
||||
if (key.endsWith(qsl("_") + postfix)) {
|
||||
key = key.replace(qsl("_") + postfix, qsl("#") + postfix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (key.endsWith("_PC")) {
|
||||
key = key.replace("_PC", "");
|
||||
}
|
||||
|
||||
if (val.contains(qsl("%1$d")) && !val.contains(qsl("%2$d"))) {
|
||||
|
||||
Reference in New Issue
Block a user