Implement RMLUI string translation via LCE StringTable

Replace hardcoded English strings in RML UI files with {IDS_XXX}
placeholders that are translated at runtime via RmlUi's TranslateString
override, which looks up keys in the LCE StringTable.

- Override SystemInterface_Win64::TranslateString to scan for {KEY}
  patterns and resolve them via StringTable::getString(wstring)
- Add GetLCEStringTable() accessor to CConsoleMinecraftApp
- Update PauseMenu.rml, SettingsMenu.rml, HelpOptions.rml with IDS_XXX keys
- Update dynamic dialog SetInnerRML calls in UIScene_PauseMenu.cpp
- Fix CMakePresets.json: remove hardcoded VS2022 ml64.exe path
This commit is contained in:
Zero
2026-06-12 15:46:34 +02:00
parent 233aea0110
commit 5355394a5a
7 changed files with 104 additions and 36 deletions

View File

@@ -1,4 +1,7 @@
#include "RmlUi_SystemInterface_Win64.h"
#include "..\Common\Consoles_App.h"
#include "StringTable.h"
#include "Windows64_App.h"
SystemInterface_Win64::SystemInterface_Win64()
{
@@ -22,7 +25,72 @@ double SystemInterface_Win64::GetElapsedTime()
int SystemInterface_Win64::TranslateString(Rml::String& translated, const Rml::String& input)
{
translated = input;
return 0;
int count = 0;
StringTable* st = app.GetLCEStringTable();
if (!st)
return 0;
std::string result;
result.reserve(input.size());
for (size_t i = 0; i < input.size(); )
{
if (input[i] == '{')
{
size_t end = input.find('}', i + 1);
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)
{
// 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
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &utf8[0], utf8len, nullptr, nullptr);
result += utf8;
count++;
}
else
{
result += input.substr(i, end - i + 1);
}
}
else
{
result += input.substr(i, end - i + 1);
}
}
else
{
result += input.substr(i, end - i + 1);
}
i = end + 1;
}
else
{
result += input[i];
i++;
}
}
else
{
result += input[i];
i++;
}
}
translated = result;
return count;
}
void SystemInterface_Win64::JoinPath(Rml::String& translated_path, const Rml::String& document_path, const Rml::String& path)