diff --git a/CMakeLists.txt b/CMakeLists.txt index 331f419e9..384646554 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -507,6 +507,7 @@ if(NINTENDO_3DS) Source/platform/ctr/messagebox.cpp Source/platform/ctr/random.cpp Source/platform/ctr/sockets.cpp + Source/platform/ctr/locale.cpp Source/platform/ctr/asio/net/if.c Source/platform/ctr/asio/sys/socket.c Source/platform/ctr/asio/sys/uio.c) diff --git a/Source/options.cpp b/Source/options.cpp index 9db58a0a6..c241a243d 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -18,6 +18,10 @@ #include #endif +#ifdef __3DS__ +#include "platform/ctr/locale.hpp" +#endif + #define SI_SUPPORT_IOSTREAMS #include @@ -329,6 +333,8 @@ void LoadOptions() sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &language); std::string locale = std::string(vita_locales[language]); sceAppUtilShutdown(); +#elif defined(__3DS__) + std::string locale = n3ds::GetLocale(); #else std::string locale = std::locale("").name().substr(0, 5); #endif diff --git a/Source/platform/ctr/locale.cpp b/Source/platform/ctr/locale.cpp new file mode 100644 index 000000000..7fe187414 --- /dev/null +++ b/Source/platform/ctr/locale.cpp @@ -0,0 +1,66 @@ +#include "platform/ctr/locale.hpp" + +#include <3ds.h> + +namespace devilution { +namespace n3ds { + +namespace { + +class CFGUService { +public: + CFGUService() + { + cfguInit(); + } + + ~CFGUService() + { + cfguExit(); + } +}; + +} + +std::string GetLocale() +{ + CFGUService cfguService; + + u8 language; + Result res = CFGU_GetSystemLanguage(&language); + + if (!R_SUCCEEDED(res)) + return ""; + + switch (language) { + case CFG_LANGUAGE_JP: + return "ja"; + case CFG_LANGUAGE_EN: + return "en"; + case CFG_LANGUAGE_FR: + return "fr"; + case CFG_LANGUAGE_DE: + return "de"; + case CFG_LANGUAGE_IT: + return "it"; + case CFG_LANGUAGE_ES: + return "es"; + case CFG_LANGUAGE_ZH: + return "zh_CN"; + case CFG_LANGUAGE_KO: + return "ko_KR"; + case CFG_LANGUAGE_NL: + return "nl"; + case CFG_LANGUAGE_PT: + return "pt_BR"; + case CFG_LANGUAGE_RU: + return "ru"; + case CFG_LANGUAGE_TW: + return "zh_TW"; + default: + return ""; + } +} + +} // namespace n3ds +} // namespace devilution diff --git a/Source/platform/ctr/locale.hpp b/Source/platform/ctr/locale.hpp new file mode 100644 index 000000000..25cf86847 --- /dev/null +++ b/Source/platform/ctr/locale.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace devilution { +namespace n3ds { + +std::string GetLocale(); + +} // namespace n3ds +} // namespace devilution