From a52b00f31eb5df1cd603975bdd31794233898a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 12 Jun 2014 11:30:24 +0200 Subject: Fix reading of entries for language/country combinations This fixes a regression introduced in 988f09bb051dca0437ecec431ee44ed5b4a560d8. The mentioned commit ensures that if the locale is e.g. "de_DE" the entry "de" will be used. But this breaks if there is a translation for another country. E.g. for "de_CH" it would also pick the "de" entry. This change now operates on both just the language code and the locale. If an entry with the language code is present it will be picked. If another entry with the exact locale is found it will be overwritten. Modifiers are not supported as this is currently missing in QLocale. REVIEW: 118692 --- src/core/kconfigini.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/core/kconfigini.cpp') diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index f4ce9410..5fe4de03 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -85,6 +85,8 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry return ParseOk; } + const QByteArray currentLanguage = currentLocale.split('_').first(); + bool bDefault = options & ParseDefaults; bool allowExecutableValues = options & ParseExpansions; @@ -251,7 +253,7 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry } printableToString(&aKey, file, lineNo); if (!locale.isEmpty()) { - if (locale != currentLocale) { + if (locale != currentLocale && locale != currentLanguage) { // backward compatibility. C == en_US if (locale.at(0) != 'C' || currentLocale != "en_US") { if (merging) { @@ -275,6 +277,9 @@ KConfigIniBackend::parseConfig(const QByteArray ¤tLocale, KEntryMap &entry } if (!locale.isNull()) { entryOptions |= KEntryMap::EntryLocalized; + if (locale.indexOf('_') != -1) { + entryOptions |= KEntryMap::EntryLocalizedCountry; + } } printableToString(&line, file, lineNo); if (entryOptions & KEntryMap::EntryRawKey) { -- cgit v1.2.1