Mercurial > minori
diff src/gui/locale.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Tue, 02 Jan 2024 06:05:06 -0500 |
parents | 975a3f0965e2 |
children | 862d0d8619f6 |
line wrap: on
line diff
--- a/src/gui/locale.cc Sun Nov 19 19:13:28 2023 -0500 +++ b/src/gui/locale.cc Tue Jan 02 06:05:06 2024 -0500 @@ -1,10 +1,14 @@ #include "gui/locale.h" #include "core/strings.h" + #include <QTranslator> #include <QLocale> #include <QDir> #include <QString> #include <QApplication> + +#include <QDebug> + #include <iostream> namespace Locale { @@ -18,12 +22,7 @@ Locale::Locale() { RefreshAvailableLocales(); - - /* default to en_US */ - if (!IsLocaleAvailable(QLocale())) - SetActiveLocale(QLocale("en_US")); - else /* TODO: is this needed? */ - SetActiveLocale(QLocale()); + SetActiveLocale(QLocale("en_US")); } Locale::Locale(const std::string& name) { @@ -52,9 +51,8 @@ QStringList translations = dir.entryList({"*.qm"}, QDir::Files); _available_translations.reserve(translations.size()); - for (const QString& str : translations) { + for (const QString& str : translations) _available_translations.push_back(QLocale(str.mid(0, str.lastIndexOf(".")))); - } } bool Locale::IsLocaleAvailable(const QLocale& locale) const { @@ -65,8 +63,9 @@ } bool Locale::SetActiveLocale(const QLocale& locale) { - if (!IsLocaleAvailable(locale)) + if (!IsLocaleAvailable(locale) || !qApp) return false; + if (_locale == locale) return true; /* we're... already on this locale :) */ @@ -101,6 +100,7 @@ if (!translator.load(path)) return false; + qApp->installTranslator(&translator); return true; }