Get system language for iOS
This commit is contained in:
parent
ef68f8377a
commit
857232fb52
@ -16,6 +16,7 @@
|
|||||||
#include "IImagePresenter.h"
|
#include "IImagePresenter.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
@ -112,6 +113,7 @@ namespace irr
|
|||||||
m_touch_id_map.clear();
|
m_touch_id_map.clear();
|
||||||
}
|
}
|
||||||
void setUpsideDown(bool val) { m_upside_down = val; }
|
void setUpsideDown(bool val) { m_upside_down = val; }
|
||||||
|
static std::string getSystemLanguageCode();
|
||||||
private:
|
private:
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void createViewAndDriver();
|
void createViewAndDriver();
|
||||||
|
@ -858,6 +858,11 @@ namespace irr
|
|||||||
{
|
{
|
||||||
[static_cast<SIrrDeviceiOSDataStorage*>(DataStorage)->View display];
|
[static_cast<SIrrDeviceiOSDataStorage*>(DataStorage)->View display];
|
||||||
}
|
}
|
||||||
|
std::string CIrrDeviceiOS::getSystemLanguageCode()
|
||||||
|
{
|
||||||
|
NSString* language = [[NSLocale preferredLanguages] firstObject];
|
||||||
|
return std::string([language UTF8String]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
|
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
|
||||||
|
@ -49,6 +49,9 @@
|
|||||||
#include "main_android.hpp"
|
#include "main_android.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IOS_STK
|
||||||
|
#include "../../lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// set to 1 to debug i18n
|
// set to 1 to debug i18n
|
||||||
#define TRANSLATE_VERBOSE 0
|
#define TRANSLATE_VERBOSE 0
|
||||||
@ -322,7 +325,14 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
|
|||||||
language = p_lang;
|
language = p_lang;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef IOS_STK
|
||||||
|
language = irr::CIrrDeviceiOS::getSystemLanguageCode();
|
||||||
|
if (language.find("zh-Hans") != std::string::npos)
|
||||||
|
language = "zh_CN";
|
||||||
|
else if (language.find("zh-Hant") != std::string::npos)
|
||||||
|
language = "zh_TW";
|
||||||
|
language = StringUtils::findAndReplace(language, "-", "_");
|
||||||
|
#elif defined(WIN32)
|
||||||
// Thanks to the frogatto developer for this code snippet:
|
// Thanks to the frogatto developer for this code snippet:
|
||||||
char c[1024];
|
char c[1024];
|
||||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME,
|
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME,
|
||||||
|
Loading…
Reference in New Issue
Block a user