mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-30 11:40:32 +00:00
win32: set menubar language to same as config
This commit is contained in:
parent
3187eecf05
commit
4e9cd6ff3e
@ -49,6 +49,8 @@
|
||||
#include "../../verbosity.h"
|
||||
#include "../../ui/drivers/ui_win32.h"
|
||||
#include "../../paths.h"
|
||||
#include "platform_win32.h"
|
||||
|
||||
#ifndef SM_SERVERR2
|
||||
#define SM_SERVERR2 89
|
||||
#endif
|
||||
@ -71,6 +73,79 @@ static bool dwm_composition_disabled;
|
||||
|
||||
static bool console_needs_free;
|
||||
|
||||
#if defined(HAVE_LANGEXTRA) && !defined(_XBOX)
|
||||
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER)
|
||||
struct win32_lang_pair
|
||||
{
|
||||
unsigned short lang_ident;
|
||||
enum retro_language lang;
|
||||
};
|
||||
|
||||
/* https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings */
|
||||
const struct win32_lang_pair win32_lang_pairs[] =
|
||||
{
|
||||
/* array order MUST be kept, always largest ID first */
|
||||
{0x7c04, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* neutral */
|
||||
{0x1404, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* MO */
|
||||
{0x1004, RETRO_LANGUAGE_CHINESE_SIMPLIFIED}, /* SG */
|
||||
{0xC04, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* HK/PRC */
|
||||
{0x816, RETRO_LANGUAGE_PORTUGUESE_PORTUGAL},
|
||||
{0x416, RETRO_LANGUAGE_PORTUGUESE_BRAZIL},
|
||||
{0x2a, RETRO_LANGUAGE_VIETNAMESE},
|
||||
{0x19, RETRO_LANGUAGE_RUSSIAN},
|
||||
{0x16, RETRO_LANGUAGE_PORTUGUESE_PORTUGAL},
|
||||
{0x15, RETRO_LANGUAGE_POLISH},
|
||||
{0x13, RETRO_LANGUAGE_DUTCH},
|
||||
{0x12, RETRO_LANGUAGE_KOREAN},
|
||||
{0x11, RETRO_LANGUAGE_JAPANESE},
|
||||
{0x10, RETRO_LANGUAGE_ITALIAN},
|
||||
{0xc, RETRO_LANGUAGE_FRENCH},
|
||||
{0xa, RETRO_LANGUAGE_SPANISH},
|
||||
{0x9, RETRO_LANGUAGE_ENGLISH},
|
||||
{0x8, RETRO_LANGUAGE_GREEK},
|
||||
{0x7, RETRO_LANGUAGE_GERMAN},
|
||||
{0x4, RETRO_LANGUAGE_CHINESE_SIMPLIFIED}, /* neutral */
|
||||
{0x1, RETRO_LANGUAGE_ARABIC},
|
||||
/* MS does not support Esperanto */
|
||||
/*{0x0, RETRO_LANGUAGE_ESPERANTO},*/
|
||||
};
|
||||
|
||||
unsigned short win32_get_langid_from_retro_lang(enum retro_language lang)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < sizeof(win32_lang_pairs) / sizeof(win32_lang_pairs[0]); i++)
|
||||
{
|
||||
if (win32_lang_pairs[i].lang == lang)
|
||||
return win32_lang_pairs[i].lang_ident;
|
||||
}
|
||||
|
||||
return 0x409; /* fallback to US English */
|
||||
}
|
||||
|
||||
enum retro_language win32_get_retro_lang_from_langid(unsigned short langid)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < sizeof(win32_lang_pairs) / sizeof(win32_lang_pairs[0]); i++)
|
||||
{
|
||||
if (win32_lang_pairs[i].lang_ident > 0x3ff)
|
||||
{
|
||||
if (langid == win32_lang_pairs[i].lang_ident)
|
||||
return win32_lang_pairs[i].lang;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((langid & 0x3ff) == win32_lang_pairs[i].lang_ident)
|
||||
return win32_lang_pairs[i].lang;
|
||||
}
|
||||
}
|
||||
|
||||
return RETRO_LANGUAGE_ENGLISH;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void gfx_dwm_shutdown(void)
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
@ -591,62 +666,7 @@ enum retro_language frontend_win32_get_user_language(void)
|
||||
#if defined(HAVE_LANGEXTRA) && !defined(_XBOX)
|
||||
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER)
|
||||
LANGID langid = GetUserDefaultUILanguage();
|
||||
unsigned i;
|
||||
|
||||
struct lang_pair
|
||||
{
|
||||
unsigned short lang_ident;
|
||||
enum retro_language lang;
|
||||
};
|
||||
|
||||
/* https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings */
|
||||
const struct lang_pair pairs[] =
|
||||
{
|
||||
/* array order MUST be kept, always largest ID first */
|
||||
{0x7c04, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* neutral */
|
||||
{0x1404, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* MO */
|
||||
{0x1004, RETRO_LANGUAGE_CHINESE_SIMPLIFIED}, /* SG */
|
||||
{0xC04, RETRO_LANGUAGE_CHINESE_TRADITIONAL}, /* HK/PRC */
|
||||
{0x816, RETRO_LANGUAGE_PORTUGUESE_PORTUGAL},
|
||||
{0x416, RETRO_LANGUAGE_PORTUGUESE_BRAZIL},
|
||||
{0x2a, RETRO_LANGUAGE_VIETNAMESE},
|
||||
{0x19, RETRO_LANGUAGE_RUSSIAN},
|
||||
{0x16, RETRO_LANGUAGE_PORTUGUESE_PORTUGAL},
|
||||
{0x15, RETRO_LANGUAGE_POLISH},
|
||||
{0x13, RETRO_LANGUAGE_DUTCH},
|
||||
{0x12, RETRO_LANGUAGE_KOREAN},
|
||||
{0x11, RETRO_LANGUAGE_JAPANESE},
|
||||
{0x10, RETRO_LANGUAGE_ITALIAN},
|
||||
{0xc, RETRO_LANGUAGE_FRENCH},
|
||||
{0xa, RETRO_LANGUAGE_SPANISH},
|
||||
{0x9, RETRO_LANGUAGE_ENGLISH},
|
||||
{0x8, RETRO_LANGUAGE_GREEK},
|
||||
{0x7, RETRO_LANGUAGE_GERMAN},
|
||||
{0x4, RETRO_LANGUAGE_CHINESE_SIMPLIFIED}, /* neutral */
|
||||
{0x1, RETRO_LANGUAGE_ARABIC},
|
||||
/* MS does not support Esperanto */
|
||||
/*{0x0, RETRO_LANGUAGE_ESPERANTO},*/
|
||||
};
|
||||
|
||||
for (i = 0; i < sizeof(pairs) / sizeof(pairs[0]); i++)
|
||||
{
|
||||
if (pairs[i].lang_ident > 0x3ff)
|
||||
{
|
||||
if (langid == pairs[i].lang_ident)
|
||||
{
|
||||
lang = pairs[i].lang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((langid & 0x3ff) == pairs[i].lang_ident)
|
||||
{
|
||||
lang = pairs[i].lang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
lang = win32_get_retro_lang_from_langid(langid);
|
||||
#endif
|
||||
#endif
|
||||
return lang;
|
||||
|
30
frontend/drivers/platform_win32.h
Normal file
30
frontend/drivers/platform_win32.h
Normal file
@ -0,0 +1,30 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
* Copyright (C) 2016-2019 - Brad Parker
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _PLATFORM_WIN32_H
|
||||
#define _PLATFORM_WIN32_H
|
||||
|
||||
#if defined(HAVE_LANGEXTRA) && !defined(_XBOX)
|
||||
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER)
|
||||
unsigned short win32_get_langid_from_retro_lang(enum retro_language lang);
|
||||
|
||||
enum retro_language win32_get_retro_lang_from_langid(unsigned short langid);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,6 +1,7 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2016-2019 - Brad Parker
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2015-2017 - Ali Bouhlel
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2016-2019 - Brad Parker
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
@ -49,6 +50,7 @@
|
||||
#include "../../paths.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../../frontend/drivers/platform_win32.h"
|
||||
|
||||
#include "ui_win32.h"
|
||||
|
||||
@ -61,6 +63,10 @@ typedef struct ui_companion_win32
|
||||
bool win32_window_init(WNDCLASSEX *wndclass,
|
||||
bool fullscreen, const char *class_name)
|
||||
{
|
||||
#if _WIN32_WINNT >= 0x0501
|
||||
/* Use the language set in the config for the menubar... also changes the console language. */
|
||||
SetThreadUILanguage(win32_get_langid_from_retro_lang(*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE)));
|
||||
#endif
|
||||
wndclass->cbSize = sizeof(WNDCLASSEX);
|
||||
wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wndclass->hInstance = GetModuleHandle(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user