diff options
Diffstat (limited to 'src/corelib/kernel/qtranslator.cpp')
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 36d9ea4998..bdcd016630 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -601,9 +601,14 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo } } - if (ok && d->do_load(reinterpret_cast<const uchar *>(d->unmapPointer), d->unmapLength, directory)) { - d->filePath = realname; - return true; + if (ok) { + const QString base_dir = + !directory.isEmpty() ? directory : QFileInfo(realname).absolutePath(); + if (d->do_load(reinterpret_cast<const uchar *>(d->unmapPointer), d->unmapLength, + base_dir)) { + d->filePath = realname; + return true; + } } #if defined(QT_USE_MMAP) @@ -650,15 +655,20 @@ static QString find_translation(const QLocale & locale, // see http://www.unicode.org/reports/tr35/#LanguageMatching for inspiration + // For each language_country returned by locale.uiLanguages(), add + // also a lowercase version to the list. Since these languages are + // used to create file names, this is important on case-sensitive + // file systems, where otherwise a file called something like + // "prefix_en_us.qm" won't be found under the "en_US" locale. Note + // that the Qt resource system is always case-sensitive, even on + // Windows (in other words: this codepath is *not* UNIX-only). QStringList languages = locale.uiLanguages(); -#if defined(Q_OS_UNIX) for (int i = languages.size()-1; i >= 0; --i) { QString lang = languages.at(i); QString lowerLang = lang.toLower(); if (lang != lowerLang) languages.insert(i+1, lowerLang); } -#endif for (QString localeName : qAsConst(languages)) { localeName.replace(QLatin1Char('-'), QLatin1Char('_')); @@ -1104,7 +1114,7 @@ void QTranslatorPrivate::clear() If \a n is not -1, it is used to choose an appropriate form for the translation (e.g. "%n file found" vs. "%n files found"). - If you need to programatically insert translations into a + If you need to programmatically insert translations into a QTranslator, this function can be reimplemented. \sa load() |