diff src/gui/locale.cc @ 195:975a3f0965e2

locale: only attempt loading locales after QApplication is init'd also the general application stuff and anime list is separated in settings
author Paper <mrpapersonic@gmail.com>
date Thu, 07 Dec 2023 11:14:01 -0500
parents 9613d72b097e
children 862d0d8619f6
line wrap: on
line diff
--- a/src/gui/locale.cc	Thu Dec 07 03:17:05 2023 -0500
+++ b/src/gui/locale.cc	Thu Dec 07 11:14:01 2023 -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 :) */