Set system language to the app on first launch (#42)

* add language on first launch

* add language on first launch

Editing the hpp aswell
This commit is contained in:
LinuxCat
2020-07-21 05:19:24 +02:00
committed by GitHub
parent 294cb9d201
commit c7340d02bb
2 changed files with 51 additions and 4 deletions
+2 -1
View File
@@ -38,6 +38,7 @@ public:
void save();
void initialize();
void addMissingThings();
void sysLang();
// Bar Color.
u32 barColor() { return this->v_barColor; }
@@ -157,4 +158,4 @@ private:
std::string v_3dsx_install_path, v_nds_install_path, v_archive_path;
};
#endif
#endif
+49 -3
View File
@@ -40,6 +40,52 @@ void Config::addMissingThings() {
}
}
//Detects system language and is used later to set app language to system language
void Config::sysLang() {
u8 language = 0;
CFGU_GetSystemLanguage(&language);
switch(language) {
case 0:
this->language("jp");
break;
case 1:
this->language("en");
break;
case 2:
this->language("fr");
break;
case 3:
this->language("de");
break;
case 4:
this->language("it");
break;
case 5:
this->language("es");
break;
case 6:
this->language("en"); //Simplified chinese, not translated
break;
case 7:
this->language("en"); //Korean, not translated
break;
case 8:
this->language("nl");
break;
case 9:
this->language("pt");
break;
case 10:
this->language("ru");
break;
case 11:
this->language("en"); //traditional chinese, not translated
break;
}
}
// In case it doesn't exist.
void Config::initialize() {
// Create through fopen "Write".
@@ -70,7 +116,7 @@ void Config::initialize() {
this->setInt("KEY_DELAY", 5);
this->setBool("SCREEN_FADE", false);
this->setBool("PROGRESS_DISPLAY", true);
this->setString("LANGUAGE", "en");
this->sysLang();
this->setBool("FIRST_STARTUP", true);
this->setBool("USE_SCRIPT_COLORS", true);
this->setBool("SHOW_SPEED", false);
@@ -250,7 +296,7 @@ Config::Config() {
}
if (!this->json.contains("LANGUAGE") || this->json.at("LANGUAGE").is_number()) {
this->language("en");
this->sysLang();
this->initialChanges = true;
} else {
this->language(this->getString("LANGUAGE"));
@@ -378,4 +424,4 @@ std::string Config::getString(const std::string &key) {
}
void Config::setString(const std::string &key, const std::string &v) {
this->json[key] = v;
}
}