From a5cd41e47ea542df7b59a98e214d2986f7226f6c Mon Sep 17 00:00:00 2001 From: Huntereb Date: Thu, 19 Dec 2019 23:50:21 -0500 Subject: [PATCH] Actually get the system language for setting langs --- source/util/lang.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/source/util/lang.cpp b/source/util/lang.cpp index 851929b..3cda11b 100755 --- a/source/util/lang.cpp +++ b/source/util/lang.cpp @@ -1,12 +1,62 @@ #include "util/lang.hpp" #include +#include +#include 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;