Detect language on first boot on Windows (Vista+) and Android

This commit is contained in:
Henrik Rydgard 2013-09-04 12:07:42 +02:00
parent 8e6b031d9b
commit ad620e463a
6 changed files with 40 additions and 8 deletions

View file

@ -21,6 +21,7 @@
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Config.h" #include "Config.h"
#include "file/ini_file.h" #include "file/ini_file.h"
#include "i18n/i18n.h"
#include "HLE/sceUtility.h" #include "HLE/sceUtility.h"
#include "Common/CPUDetect.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("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
general->Get("CurrentDirectory", &currentDirectory, ""); general->Get("CurrentDirectory", &currentDirectory, "");
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false); 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("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
general->Get("EnableCheats", &bEnableCheats, false); general->Get("EnableCheats", &bEnableCheats, false);
general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false); general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);

View file

@ -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 // 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 // it under the terms of the GNU General Public License as published by

View file

@ -15,6 +15,7 @@
// Official git repository and contact information can be found at // Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <WinNls.h>
#include "Common/CommonWindows.h" #include "Common/CommonWindows.h"
#include "file/vfs.h" #include "file/vfs.h"
@ -51,6 +52,8 @@
CDisasm *disasmWindow[MAX_CPUCOUNT] = {0}; CDisasm *disasmWindow[MAX_CPUCOUNT] = {0};
CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0}; CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0};
static std::string langRegion;
void LaunchBrowser(const char *url) { void LaunchBrowser(const char *url) {
ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL); 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: case SYSPROP_NAME:
return "PC:Windows"; return "PC:Windows";
case SYSPROP_LANGREGION: case SYSPROP_LANGREGION:
return "en_US"; return langRegion;
default: default:
return ""; return "";
} }
@ -87,7 +90,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
hideLog = false; hideLog = false;
#endif #endif
// The rest is handled in NativeInit(). // The rest is handled in NativeInit().
for (int i = 1; i < __argc; ++i) 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(); g_Config.Load();
LogManager::Init(); LogManager::Init();
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);
VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));
//Windows, API init stuff //Windows, API init stuff
INITCOMMONCONTROLSEX comm; INITCOMMONCONTROLSEX comm;

View file

@ -12,7 +12,8 @@
#include "Core/Host.h" #include "Core/Host.h"
#include "Log.h" #include "Log.h"
#include "LogManager.h" #include "LogManager.h"
#include "native/input/input_state.h" #include "base/NativeApp.h"
#include "input/input_state.h"
#include "Compare.h" #include "Compare.h"
#include "StubHost.h" #include "StubHost.h"
@ -57,6 +58,8 @@ void GL_SwapBuffers() { }
void NativeUpdate(InputState &input_state) { } void NativeUpdate(InputState &input_state) { }
void NativeRender() { } void NativeRender() { }
std::string System_GetProperty(SystemProperty prop) { return ""; }
#ifndef _WIN32 #ifndef _WIN32
InputState input_state; InputState input_state;
#endif #endif

2
native

@ -1 +1 @@
Subproject commit 1790bd8b7ef1318abccc4d92ad5b89464d42fd0e Subproject commit fee82ce2883af4627dd23060cf76226594925482

View file

@ -30,6 +30,7 @@
#include <cmath> #include <cmath>
#include <string> #include <string>
#include "base/NativeApp.h"
#include "Common/ArmEmitter.h" #include "Common/ArmEmitter.h"
#include "ext/disarm.h" #include "ext/disarm.h"
#include "math/math_util.h" #include "math/math_util.h"
@ -41,6 +42,7 @@
#define RET(a) if (!(a)) { return false; } #define RET(a) if (!(a)) { return false; }
std::string System_GetProperty(SystemProperty prop) { return ""; }
bool CheckLast(ArmGen::ARMXEmitter &emit, const char *comp) { bool CheckLast(ArmGen::ARMXEmitter &emit, const char *comp) {
u32 instr; u32 instr;