Mercurial > minori
comparison src/gui/locale.cc @ 295:b82841e76e79
*: better support on Windows
things now look much better in dark mode
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Sun, 12 May 2024 20:24:09 -0400 |
| parents | 862d0d8619f6 |
| children | b1f625b0227c |
comparison
equal
deleted
inserted
replaced
| 294:99cbc51433e4 | 295:b82841e76e79 |
|---|---|
| 5 #include <QDir> | 5 #include <QDir> |
| 6 #include <QLocale> | 6 #include <QLocale> |
| 7 #include <QString> | 7 #include <QString> |
| 8 #include <QTranslator> | 8 #include <QTranslator> |
| 9 | 9 |
| 10 #include <QDebug> | 10 #include <QtGlobal> |
| 11 | |
| 12 #include <iostream> | |
| 13 | 11 |
| 14 namespace Locale { | 12 namespace Locale { |
| 15 | 13 |
| 16 std::string GetLocaleFullName(const QLocale& locale) { | 14 std::string GetLocaleFullName(const QLocale& locale) { |
| 17 QString res = QLocale::languageToString(locale.language()); | 15 QString res = QLocale::languageToString(locale.language()); |
| 16 #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) | |
| 17 /* silence deprecation warning for locale.country() */ | |
| 18 if (locale.territory() != QLocale::AnyTerritory) | |
| 19 res += " (" + QLocale::territoryToString(locale.territory()) + ")"; | |
| 20 #else | |
| 18 if (locale.country() != QLocale::AnyCountry) | 21 if (locale.country() != QLocale::AnyCountry) |
| 19 res += " (" + QLocale::countryToString(locale.country()) + ")"; | 22 res += " (" + QLocale::countryToString(locale.country()) + ")"; |
| 23 #endif | |
| 20 return Strings::ToUtf8String(res); | 24 return Strings::ToUtf8String(res); |
| 21 } | 25 } |
| 22 | 26 |
| 23 Locale::Locale() { | 27 Locale::Locale() { |
| 24 RefreshAvailableLocales(); | 28 RefreshAvailableLocales(); |
| 80 return_value = false; | 84 return_value = false; |
| 81 | 85 |
| 82 const QString path = qApp->applicationDirPath(); | 86 const QString path = qApp->applicationDirPath(); |
| 83 if (!SwitchTranslator(_translator_qt, path + QString("/translations/qt_%1.qm").arg(name))) { | 87 if (!SwitchTranslator(_translator_qt, path + QString("/translations/qt_%1.qm").arg(name))) { |
| 84 /* Sometimes Qt will have proper translations for the language, but not the specific | 88 /* Sometimes Qt will have proper translations for the language, but not the specific |
| 85 country. In that case, we still want to use that language. */ | 89 * country. In that case, we still want to use that language. */ |
| 86 const int underscore_index = name.lastIndexOf("_"); | 90 const int underscore_index = name.lastIndexOf("_"); |
| 87 if (!underscore_index) | 91 if (!underscore_index) |
| 88 return false; | 92 return false; |
| 89 | 93 |
| 90 const QString short_name = name.mid(0, underscore_index); | 94 const QString short_name = name.mid(0, underscore_index); |
