diff --git a/src/86box.c b/src/86box.c index eca8544a5..a3ddd43ae 100644 --- a/src/86box.c +++ b/src/86box.c @@ -433,6 +433,7 @@ usage: #endif printf("-F or --fullscreen - start in fullscreen mode\n"); #ifdef _WIN32 + printf("-G or --lang langid - start the application with the specified language\n"); printf("-H or --hwnd id,hwnd - sends back the main dialog's hwnd\n"); #endif printf("-L or --logfile path - set 'path' to be the logfile\n"); @@ -512,6 +513,18 @@ usage: uid = (uint32_t *) &unique_id; shwnd = (uint32_t *) &source_hwnd; sscanf(argv[++c], "%08X%08X,%08X%08X", uid + 1, uid, shwnd + 1, shwnd); + } else if (!strcasecmp(argv[c], "--lang") || + !strcasecmp(argv[c], "-G")) { + + + //This function is currently unimplemented for *nix. + + if (!plat_set_language(argv[++c])) + printf("\nWarning: Invalid language code, ignoring --lang parameter.\n\n"); + + //The return value of 0 only means that the code is invalid, + // not related to that translation is exists or not for the + // selected language. #endif } else if (!strcasecmp(argv[c], "--test")) { /* some (undocumented) test function here.. */ diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index d413add7d..e28a40fc7 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -121,6 +121,7 @@ extern void plat_setfullscreen(int on); extern void plat_resize(int x, int y); extern void plat_vidapi_enable(int enabled); extern void plat_vid_reload_options(void); +extern int plat_set_language(char* langcode); /* Resource management. */ extern void set_language(int id); diff --git a/src/unix/unix.c b/src/unix/unix.c index 286b937bd..7683dcd67 100644 --- a/src/unix/unix.c +++ b/src/unix/unix.c @@ -1220,6 +1220,14 @@ char* plat_vidapi_name(int i) { return "default"; } + +/* Sets up the program language before initialization. */ +int plat_set_language(char* langcode) +{ + /* or maybe not */ + return 0; +} + void joystick_init(void) {} void joystick_close(void) {} void joystick_process(void) {} diff --git a/src/win/languages/hu-HU.rc b/src/win/languages/hu-HU.rc index 68a25c27e..f8fdbc41d 100644 --- a/src/win/languages/hu-HU.rc +++ b/src/win/languages/hu-HU.rc @@ -5,7 +5,7 @@ // #ifdef _WIN32 -LANGUAGE 0x0E,0x01 +LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT #pragma code_page(65001) #endif //_WIN32 diff --git a/src/win/win.c b/src/win/win.c index 6e397b98f..30f3412d9 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -1163,6 +1163,23 @@ plat_vid_reload_options(void) vid_apis[vid_api].reload(); } +/* Sets up the program language before initialization. */ +int +plat_set_language(char* langcode) +{ + int len = mbstoc16s(NULL, langcode, 0) + 1; + wchar_t *temp = malloc(len * sizeof(wchar_t)); + mbstoc16s(temp, langcode, len); + + LCID lcid = LocaleNameToLCID((LPWSTR)temp, 0); + + free(temp); + + if (lcid) + return (SetThreadUILanguage(lcid) == lcid); + else + return 0; +} void take_screenshot(void)