Added system language text change (#15)
This commit is contained in:
parent
1730ed1889
commit
0cb9f3961f
@ -1,19 +1,32 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
|
||||||
//TODO: Update this once libnx supports settings get-language.
|
#ifdef SWITCH
|
||||||
|
#define STR_JP(_str) [SetLanguage_JA] = _str
|
||||||
#define STR_JP(_str) [/*CFG_LANGUAGE_JP*/0] = _str
|
#define STR_EN(_str) [SetLanguage_ENUS] = _str, [SetLanguage_ENGB] = _str
|
||||||
#define STR_EN(_str) [/*CFG_LANGUAGE_EN*/1] = _str
|
#define STR_FR(_str) [SetLanguage_FR] = _str, [SetLanguage_FRCA] = _str
|
||||||
#define STR_FR(_str) [/*CFG_LANGUAGE_FR*/2] = _str
|
#define STR_DE(_str) [SetLanguage_DE] = _str
|
||||||
#define STR_DE(_str) [/*CFG_LANGUAGE_DE*/3] = _str
|
#define STR_IT(_str) [SetLanguage_IT] = _str
|
||||||
#define STR_IT(_str) [/*CFG_LANGUAGE_IT*/4] = _str
|
#define STR_ES(_str) [SetLanguage_ES] = _str, [SetLanguage_ES419] = _str
|
||||||
#define STR_ES(_str) [/*CFG_LANGUAGE_ES*/5] = _str
|
#define STR_ZH(_str) [SetLanguage_ZHCN] = _str
|
||||||
#define STR_ZH(_str) [/*CFG_LANGUAGE_ZH*/6] = _str
|
#define STR_KO(_str) [SetLanguage_KO] = _str
|
||||||
#define STR_KO(_str) [/*CFG_LANGUAGE_KO*/7] = _str
|
#define STR_NL(_str) [SetLanguage_NL] = _str
|
||||||
#define STR_NL(_str) [/*CFG_LANGUAGE_NL*/8] = _str
|
#define STR_PT(_str) [SetLanguage_PT] = _str
|
||||||
#define STR_PT(_str) [/*CFG_LANGUAGE_PT*/9] = _str
|
#define STR_RU(_str) [SetLanguage_RU] = _str
|
||||||
#define STR_RU(_str) [/*CFG_LANGUAGE_RU*/10] = _str
|
#define STR_TW(_str) [SetLanguage_ZHTW] = _str
|
||||||
#define STR_TW(_str) [/*CFG_LANGUAGE_TW*/11] = _str
|
#else
|
||||||
|
#define STR_JP(_str) [0] = _str
|
||||||
|
#define STR_EN(_str) [1] = _str
|
||||||
|
#define STR_FR(_str) [2] = _str
|
||||||
|
#define STR_DE(_str) [3] = _str
|
||||||
|
#define STR_IT(_str) [4] = _str
|
||||||
|
#define STR_ES(_str) [5] = _str
|
||||||
|
#define STR_ZH(_str) [6] = _str
|
||||||
|
#define STR_KO(_str) [7] = _str
|
||||||
|
#define STR_NL(_str) [8] = _str
|
||||||
|
#define STR_PT(_str) [9] = _str
|
||||||
|
#define STR_RU(_str) [10] = _str
|
||||||
|
#define STR_TW(_str) [11] = _str
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* const g_strings[StrId_Max][16] =
|
const char* const g_strings[StrId_Max][16] =
|
||||||
{
|
{
|
||||||
@ -234,7 +247,7 @@ const char* const g_strings[StrId_Max][16] =
|
|||||||
{
|
{
|
||||||
STR_EN("Version"),
|
STR_EN("Version"),
|
||||||
STR_ES("Versión"),
|
STR_ES("Versión"),
|
||||||
STR_DE("Ausführung"),
|
STR_DE("Version"),
|
||||||
STR_FR("Version"),
|
STR_FR("Version"),
|
||||||
STR_IT("Versione"),
|
STR_IT("Versione"),
|
||||||
STR_JP("バージョン"),
|
STR_JP("バージョン"),
|
||||||
@ -278,6 +291,12 @@ const char* const g_strings[StrId_Max][16] =
|
|||||||
STR_TW("打开"),
|
STR_TW("打开"),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
[StrId_Actions_Back] =
|
||||||
|
{
|
||||||
|
STR_EN("Back"),
|
||||||
|
STR_DE("Zurück"),
|
||||||
|
},
|
||||||
|
|
||||||
/*[StrId_Reboot] =
|
/*[StrId_Reboot] =
|
||||||
{
|
{
|
||||||
STR_EN(
|
STR_EN(
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#ifdef SWITCH
|
||||||
|
#include <switch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -16,6 +19,7 @@ typedef enum
|
|||||||
StrId_AppInfo_Version,
|
StrId_AppInfo_Version,
|
||||||
StrId_Actions_Launch,
|
StrId_Actions_Launch,
|
||||||
StrId_Actions_Open,
|
StrId_Actions_Open,
|
||||||
|
StrId_Actions_Back,
|
||||||
|
|
||||||
StrId_Reboot,
|
StrId_Reboot,
|
||||||
StrId_ReturnToHome,
|
StrId_ReturnToHome,
|
||||||
|
@ -316,7 +316,7 @@ void drawBackBtn(menu_s* menu, bool emptyDir) {
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
drawImage(x_image, 720 - 48, 32, 32, themeCurrent.buttonBImage, IMAGE_MODE_RGBA32);
|
drawImage(x_image, 720 - 48, 32, 32, themeCurrent.buttonBImage, IMAGE_MODE_RGBA32);
|
||||||
DrawText(interuiregular18, x_text, 720 - 47, themeCurrent.textColor, "Back");
|
DrawText(interuiregular18, x_text, 720 - 47, themeCurrent.textColor, textGetString(StrId_Actions_Back));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,25 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|
||||||
//TODO: Update this once libnx supports settings get-language.
|
#ifdef SWITCH
|
||||||
|
static int s_textLang = SetLanguage_ENUS;
|
||||||
|
#else
|
||||||
|
static int s_textLang = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int s_textLang = /*CFG_LANGUAGE_EN*/1;
|
void textInit(void) {
|
||||||
|
#ifdef SWITCH
|
||||||
|
u64 LanguageCode=0;
|
||||||
|
s32 Language=0;
|
||||||
|
Result rc = setInitialize();
|
||||||
|
s_textLang = SetLanguage_ENUS;
|
||||||
|
if (R_SUCCEEDED(rc)) rc = setGetSystemLanguage(&LanguageCode);
|
||||||
|
if (R_SUCCEEDED(rc)) rc = setMakeLanguage(LanguageCode, &Language);
|
||||||
|
if (R_SUCCEEDED(rc) && Language < 16) s_textLang = Language;
|
||||||
|
setExit();
|
||||||
|
#else
|
||||||
|
s_textLang = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int textGetLang(void) {
|
int textGetLang(void) {
|
||||||
return s_textLang;
|
return s_textLang;
|
||||||
@ -10,6 +27,10 @@ int textGetLang(void) {
|
|||||||
|
|
||||||
const char* textGetString(StrId id) {
|
const char* textGetString(StrId id) {
|
||||||
const char* str = g_strings[id][s_textLang];
|
const char* str = g_strings[id][s_textLang];
|
||||||
if (!str) str = g_strings[id][/*CFG_LANGUAGE_EN*/1];
|
#ifdef SWITCH
|
||||||
|
if (!str) str = g_strings[id][SetLanguage_ENUS];
|
||||||
|
#else
|
||||||
|
if (!str) str = g_strings[id][1];
|
||||||
|
#endif
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
|
||||||
|
void textInit(void);
|
||||||
int textGetLang(void);
|
int textGetLang(void);
|
||||||
const char* textGetString(StrId id);
|
const char* textGetString(StrId id);
|
||||||
|
@ -26,6 +26,7 @@ int main(int argc, char **argv)
|
|||||||
setsysInitialize();
|
setsysInitialize();
|
||||||
setsysGetColorSetId(&theme);
|
setsysGetColorSetId(&theme);
|
||||||
themeStartup((ThemePreset)theme);
|
themeStartup((ThemePreset)theme);
|
||||||
|
textInit();
|
||||||
menuStartup();
|
menuStartup();
|
||||||
|
|
||||||
launchInit();
|
launchInit();
|
||||||
|
@ -16,6 +16,7 @@ int main()
|
|||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(60);
|
||||||
|
|
||||||
themeStartup(THEME_PRESET_LIGHT);
|
themeStartup(THEME_PRESET_LIGHT);
|
||||||
|
textInit();
|
||||||
menuStartup();
|
menuStartup();
|
||||||
|
|
||||||
while (window.isOpen())
|
while (window.isOpen())
|
||||||
|
Loading…
Reference in New Issue
Block a user