Actually get the system language for setting langs
This commit is contained in:
parent
8bbfaac336
commit
a5cd41e47e
@ -1,12 +1,62 @@
|
||||
#include "util/lang.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <switch.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace Language {
|
||||
json lang;
|
||||
|
||||
void Load() {
|
||||
std::ifstream ifs("romfs:/lang/en.json");
|
||||
std::ifstream ifs;
|
||||
std::string languagePath;
|
||||
setInitialize();
|
||||
u64 lcode = 0;
|
||||
SetLanguage ourLang = SetLanguage_ENUS;
|
||||
setGetSystemLanguage(&lcode);
|
||||
setMakeLanguage(lcode, &ourLang);
|
||||
setExit();
|
||||
switch (ourLang) {
|
||||
case 0:
|
||||
languagePath = "romfs:/lang/ja.json";
|
||||
break;
|
||||
case 2:
|
||||
case 13:
|
||||
languagePath = "romfs:/lang/fr.json";
|
||||
break;
|
||||
case 3:
|
||||
languagePath = "romfs:/lang/de.json";
|
||||
break;
|
||||
case 4:
|
||||
languagePath = "romfs:/lang/it.json";
|
||||
break;
|
||||
case 5:
|
||||
case 14:
|
||||
languagePath = "romfs:/lang/es.json";
|
||||
break;
|
||||
case 6:
|
||||
languagePath = "romfs:/lang/zh-CN.json";
|
||||
break;
|
||||
case 7:
|
||||
languagePath = "romfs:/lang/ko.json";
|
||||
break;
|
||||
case 8:
|
||||
languagePath = "romfs:/lang/nl.json";
|
||||
break;
|
||||
case 9:
|
||||
languagePath = "romfs:/lang/pt.json";
|
||||
break;
|
||||
case 10:
|
||||
languagePath = "romfs:/lang/ru.json";
|
||||
break;
|
||||
case 11:
|
||||
languagePath = "romfs:/lang/zh-TW.json";
|
||||
break;
|
||||
default:
|
||||
languagePath = "romfs:/lang/en.json";
|
||||
}
|
||||
if (std::filesystem::exists(languagePath)) ifs = std::ifstream(languagePath);
|
||||
else ifs = std::ifstream("romfs:/lang/en.json");
|
||||
if (!ifs.good()) {
|
||||
std::cout << "[FAILED TO LOAD LANGUAGE FILE]" << std::endl;
|
||||
return;
|
||||
|
Reference in New Issue
Block a user