summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-08-16 21:33:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-19 18:46:59 +0200
commit19797d40350d07afea2e706e45ec44a6fdf05250 (patch)
tree69df03da1af1ad6c62bc465c19bf90d216569131
parent35139d45ce7fee0e1c9c0409d31b710ef35c3970 (diff)
fix handling of country-less languages like esperanto
it's impossible to instantiate QLocale objects like that, so the language setting would be simply clobbered. instead, we now convert between numerical and string codes directly. unfortunately QLocale has no public api for that. but we are including private QTranslator headers already anyway, so whatever. Task-number: QTBUG-14592 Change-Id: I95189c1898aa1fb5520ecf7057521597ed9331f1 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r--src/linguist/shared/translator.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp
index f5f4ab789..37929f394 100644
--- a/src/linguist/shared/translator.cpp
+++ b/src/linguist/shared/translator.cpp
@@ -62,6 +62,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QTextStream>
+#include <private/qlocale_p.h>
#include <private/qtranslator_p.h>
QT_BEGIN_NAMESPACE
@@ -367,30 +368,19 @@ bool Translator::save(const QString &filename, ConversionData &cd, const QString
QString Translator::makeLanguageCode(QLocale::Language language, QLocale::Country country)
{
- QLocale locale(language, country);
- if (country == QLocale::AnyCountry) {
- QString languageCode = locale.name().section(QLatin1Char('_'), 0, 0);
- if (languageCode.length() <= 3)
- return languageCode;
- return QString();
- } else {
- return locale.name();
+ QString result = QLocalePrivate::languageToCode(language);
+ if (language != QLocale::C && country != QLocale::AnyCountry) {
+ result.append(QLatin1Char('_'));
+ result.append(QLocalePrivate::countryToCode(country));
}
+ return result;
}
void Translator::languageAndCountry(const QString &languageCode,
QLocale::Language *lang, QLocale::Country *country)
{
- QLocale locale(languageCode);
- if (lang)
- *lang = locale.language();
-
- if (country) {
- if (languageCode.indexOf(QLatin1Char('_')) != -1)
- *country = locale.country();
- else
- *country = QLocale::AnyCountry;
- }
+ QLocale::Script script;
+ QLocalePrivate::getLangAndCountry(languageCode, *lang, script, *country);
}
int Translator::find(const TranslatorMessage &msg) const