diff --git a/Core/Config.cpp b/Core/Config.cpp index 0177349122b2..bb958935c01c 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -21,6 +21,7 @@ #include "Common/FileUtil.h" #include "Config.h" #include "file/ini_file.h" +#include "i18n/i18n.h" #include "HLE/sceUtility.h" #include "Common/CPUDetect.h" @@ -55,7 +56,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true); general->Get("CurrentDirectory", ¤tDirectory, ""); general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false); - general->Get("Language", &languageIni, "en_US"); + + std::string defaultLangRegion = "en_US"; + if (bFirstRun) { + std::string langRegion = System_GetProperty(SYSPROP_LANGREGION); + if (i18nrepo.IniExists(langRegion)) + defaultLangRegion = langRegion; + // TODO: Be smart about same language, different country + } + + general->Get("Language", &languageIni, defaultLangRegion.c_str()); general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores); general->Get("EnableCheats", &bEnableCheats, false); general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 5e6676bd40f7..a3fbdf13be48 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013- PPSSPP Project. +// Copyright (c) 2013- PPSSPP Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/Windows/main.cpp b/Windows/main.cpp index 02cd2aa3eeb2..f5056cfdd604 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include "Common/CommonWindows.h" #include "file/vfs.h" @@ -51,6 +52,8 @@ CDisasm *disasmWindow[MAX_CPUCOUNT] = {0}; CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0}; +static std::string langRegion; + void LaunchBrowser(const char *url) { ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL); } @@ -60,7 +63,7 @@ std::string System_GetProperty(SystemProperty prop) { case SYSPROP_NAME: return "PC:Windows"; case SYSPROP_LANGREGION: - return "en_US"; + return langRegion; default: return ""; } @@ -87,7 +90,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin hideLog = false; #endif - // The rest is handled in NativeInit(). for (int i = 1; i < __argc; ++i) { @@ -109,14 +111,29 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin } } + VFSRegister("", new DirectoryAssetReader("assets/")); + VFSRegister("", new DirectoryAssetReader("")); + + wchar_t lcCountry[256]; + + // LOCALE_SNAME is only available in WinVista+ + // Really should find a way to do this in XP too :/ + if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) { + langRegion = ConvertWStringToUTF8(lcCountry); + for (int i = 0; i < langRegion.size(); i++) { + if (langRegion[i] == '-') + langRegion[i] = '_'; + } + } else { + langRegion = "en_US"; + } + g_Config.Load(); LogManager::Init(); LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); - VFSRegister("", new DirectoryAssetReader("assets/")); - VFSRegister("", new DirectoryAssetReader("")); //Windows, API init stuff INITCOMMONCONTROLSEX comm; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 68c7cd7365b7..ce42f7ffe558 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -12,7 +12,8 @@ #include "Core/Host.h" #include "Log.h" #include "LogManager.h" -#include "native/input/input_state.h" +#include "base/NativeApp.h" +#include "input/input_state.h" #include "Compare.h" #include "StubHost.h" @@ -57,6 +58,8 @@ void GL_SwapBuffers() { } void NativeUpdate(InputState &input_state) { } void NativeRender() { } +std::string System_GetProperty(SystemProperty prop) { return ""; } + #ifndef _WIN32 InputState input_state; #endif diff --git a/native b/native index 1790bd8b7ef1..fee82ce2883a 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 1790bd8b7ef1318abccc4d92ad5b89464d42fd0e +Subproject commit fee82ce2883af4627dd23060cf76226594925482 diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index cb77b0e1a877..66ed8687724d 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -30,6 +30,7 @@ #include #include +#include "base/NativeApp.h" #include "Common/ArmEmitter.h" #include "ext/disarm.h" #include "math/math_util.h" @@ -41,6 +42,7 @@ #define RET(a) if (!(a)) { return false; } +std::string System_GetProperty(SystemProperty prop) { return ""; } bool CheckLast(ArmGen::ARMXEmitter &emit, const char *comp) { u32 instr;