From 72546b83a7b39ef2949f0a30dcfd81c1ab7c6e18 Mon Sep 17 00:00:00 2001 From: The Dax Date: Wed, 12 Feb 2014 18:31:54 -0500 Subject: [PATCH] Allow the language ini path to be overridden for translation testing purposes. --- UI/MiscScreens.cpp | 14 +++++++++++++- UI/NativeApp.cpp | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index a830f2643a..2ba00c00e6 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -36,6 +36,7 @@ #include "Core/MIPS/JitCommon/JitCommon.h" #include "Core/HLE/sceUtility.h" #include "Common/CPUDetect.h" +#include "Common/FileUtil.h" #include "ui_atlas.h" @@ -320,7 +321,18 @@ void NewLanguageScreen::OnCompleted(DialogResult result) { g_Config.sLanguageIni = code; - if (i18nrepo.LoadIni(g_Config.sLanguageIni)) { + bool iniLoadedSuccessfully = false; + // Allow the lang directory to be overridden for testing purposes (e.g. Android, where it's hard to + // test new languages without recompiling the entire app, which is a hassle). + const std::string langOverridePath = g_Config.memCardDirectory + "PSP/SYSTEM/lang/"; + + // If we run into the unlikely case that "lang" is actually a file, just use the built-in translations. + if (!File::Exists(langOverridePath) || !File::IsDirectory(langOverridePath)) + iniLoadedSuccessfully = i18nrepo.LoadIni(g_Config.sLanguageIni); + else + iniLoadedSuccessfully = i18nrepo.LoadIni(g_Config.sLanguageIni, langOverridePath); + + if (iniLoadedSuccessfully) { // Dunno what else to do here. if (langValuesMapping.find(code) == langValuesMapping.end()) { // Fallback to English diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index fbad008ee8..aec24b7b78 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -383,8 +383,16 @@ void NativeInit(int argc, const char *argv[], if (!gfxLog) logman->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); #endif + // Allow the lang directory to be overridden for testing purposes (e.g. Android, where it's hard to + // test new languages without recompiling the entire app, which is a hassle). + const std::string langOverridePath = g_Config.memCardDirectory + "PSP/SYSTEM/lang/"; + + // If we run into the unlikely case that "lang" is actually a file, just use the built-in translations. + if (!File::Exists(langOverridePath) || !File::IsDirectory(langOverridePath)) + i18nrepo.LoadIni(g_Config.sLanguageIni); + else + i18nrepo.LoadIni(g_Config.sLanguageIni, langOverridePath); - i18nrepo.LoadIni(g_Config.sLanguageIni); I18NCategory *d = GetI18NCategory("DesktopUI"); // Note to translators: do not translate this/add this to PPSSPP-lang's files. // It's intended to be custom for every user.