Add StringTableNameMap.h with 2312 name-to-ID entries for static mode fallback

This commit is contained in:
Zero
2026-06-12 21:06:16 +02:00
parent 5355394a5a
commit 5f55b271f4
6 changed files with 2389 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
#include "..\Common\Consoles_App.h"
#include "StringTable.h"
#include "Windows64_App.h"
#include "..\Assets\Localisation\strings.h"
#include "StringTableNameMap.h"
SystemInterface_Win64::SystemInterface_Win64()
{
@@ -42,20 +44,24 @@ int SystemInterface_Win64::TranslateString(Rml::String& translated, const Rml::S
if (end != Rml::String::npos)
{
Rml::String key = input.substr(i + 1, end - i - 1);
// Convert UTF-8 key to wide string for StringTable lookup
int wlen = MultiByteToWideChar(CP_UTF8, 0, key.c_str(), (int)key.size(), nullptr, 0);
if (wlen > 0)
{
std::wstring wkey(wlen, L'\0');
MultiByteToWideChar(CP_UTF8, 0, key.c_str(), (int)key.size(), &wkey[0], wlen);
LPCWSTR wstr = st->getString(wkey);
if (!wstr || wcslen(wstr) == 0)
{
int id = GetStringIDByName(wkey);
if (id >= 0)
wstr = st->getString(id);
}
if (wstr && wcslen(wstr) > 0)
{
// Convert wide result back to UTF-8
int utf8len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
if (utf8len > 0)
{
std::string utf8(utf8len - 1, '\0'); // -1 for null terminator
std::string utf8(utf8len - 1, '\0');
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &utf8[0], utf8len, nullptr, nullptr);
result += utf8;
count++;