33 std::pair<std::string, std::string>
extractLang(
const std::string& info)
35 String lang_long =
"";
36 String lang_short =
"";
37 for (
const auto& line : StringUtil::split(info,
"\n"))
39 auto token = StringUtil::split(line);
40 if (token[0] ==
"Language-Team:")
42 else if (token[0] ==
"Language:")
43 lang_short = token[1];
45 return {lang_long, lang_short};
48 void LanguageEngine::setup()
52 languages = { {
"English",
"en"} };
53 auto& moFileReader = moFileLib::moFileReaderSingleton::GetInstance();
56 ResourceGroupManager::getSingleton().addResourceLocation(base_path,
"FileSystem",
"LngRG");
57 FileInfoListPtr fl = ResourceGroupManager::getSingleton().findResourceFileInfo(
"LngRG",
"*",
true);
60 for (
const auto&
file : *fl)
63 String mo_path =
PathCombine(locale_path,
"ror.mo");
64 if (moFileReader.ReadFile(mo_path.c_str()) == moFileLib::moFileReader::EC_SUCCESS)
66 String info = moFileLib::moFileReaderSingleton::GetInstance().Lookup(
"");
70 std::sort(languages.begin() + 1, languages.end());
71 moFileReader.ClearTable();
73 ResourceGroupManager::getSingleton().destroyResourceGroup(
"LngRG");
76 String mo_path =
PathCombine(locale_path,
"ror.mo");
78 if (moFileReader.ReadFile(mo_path.c_str()) == moFileLib::moFileReader::EC_SUCCESS)
80 String info = moFileLib::moFileReaderSingleton::GetInstance().Lookup(
"");
82 RoR::LogFormat(
"[RoR|App] Loading language file '%s'", mo_path.c_str());
86 RoR::LogFormat(
"[RoR|App] Error loading language file: '%s'", mo_path.c_str());
90 RoR::Log(
"[RoR|App] Language successfully loaded");