[Bugfix] FS#13908 hotkeys not saved when language is changed

Lang IDs get localized, if using them in a setting they should be
converted to english

adds lang_id_to_english() which walks the core builtins to return the lang id in english

Change-Id: Iced0d70be1318e512a8f3756e2bef1102dc511d8
This commit is contained in:
William Wilgus 2026-05-26 01:09:05 -04:00
parent e471fe4115
commit 239ba599fd
3 changed files with 25 additions and 3 deletions

View file

@ -147,6 +147,25 @@ int lang_english_to_id(const char *english)
return -1;
}
const char * lang_id_to_english(int lang_id)
{
int i;
unsigned char *ptr = (unsigned char *) core_language_builtin;
if (lang_id >= 0 && lang_id < LANG_LAST_INDEX_IN_ARRAY)
{
if (language_strings[0] == ptr) /* already in english */
return str(lang_id);
for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) {
if (i == lang_id)
return ptr;
ptr += strlen((char *)ptr) + 1; /* advance pointer to next string */
}
}
return ""; /* Not found */
}
int lang_is_rtl(void)
{
return (lang_options & LANGUAGE_FLAG_RTL) != 0;

View file

@ -34,6 +34,8 @@ int lang_load(const char *filename, const unsigned char *builtin,
/* get the ID of an english string so it can be localised */
int lang_english_to_id(const char *english);
/* get the english string of a given id */
const char * lang_id_to_english(int lang_id);
/* returns whether the loaded language is a right-to-left language */
int lang_is_rtl(void);

View file

@ -67,6 +67,7 @@
#ifdef HAVE_DISK_STORAGE
#include "storage.h"
#endif
#include "language.h"
static int onplay_result = ONPLAY_OK;
static bool in_queue_submenu = false;
@ -1823,8 +1824,8 @@ void wps_context_menu_load_from_cfg(void* setting, char *value)
for (size_t i = ARRAYLEN(hotkey_items) - 1; i < ARRAYLEN(hotkey_items); i--)
{
if (end-st > 1
&& strncasecmp(st, str(hotkey_items[i].lang_id), end-st) == 0)
if (end-st > 1 &&
strncasecmp(st, lang_id_to_english(hotkey_items[i].lang_id), end-st) == 0)
{
var |= HK_CTX_SET(item, hotkey_items[i].action);
}
@ -1851,7 +1852,7 @@ char* wps_context_menu_write_to_cfg(void* setting, char*buf, int buf_len)
for (int i = 0; i < items && buf_len > 0; i++)
{
written = snprintf(buffer, buf_len, "%s, ",
str(get_hotkey(HK_CTX_GET(i, var))->lang_id));
lang_id_to_english(get_hotkey(HK_CTX_GET(i, var))->lang_id));
buf_len -= written;
buffer += written;
}