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

@@ -1,5 +1,18 @@
#include "RmlManager.h"
#pragma push_macro("byte")
#pragma push_macro("GetNextSibling")
#pragma push_macro("GetFirstChild")
#undef byte
#undef GetNextSibling
#undef GetFirstChild
#include <RmlUi/Core/ElementText.h>
#pragma pop_macro("GetFirstChild")
#pragma pop_macro("GetNextSibling")
#pragma pop_macro("byte")
extern ID3D11Device* g_pd3dDevice;
extern ID3D11DeviceContext* g_pImmediateContext;
extern ID3D11RenderTargetView* g_pRenderTargetView;
@@ -190,4 +203,38 @@ void RmlManager::UpdateDpRatio()
dp_ratio = 3.0f;
m_context->SetDensityIndependentPixelRatio(dp_ratio);
}
static void ReTranslateElement(Rml::Element* elem, Rml::SystemInterface* system_if)
{
Rml::ElementText* text_elem = rmlui_dynamic_cast<Rml::ElementText*>(elem);
if (text_elem)
{
const Rml::Variant* src = elem->GetAttribute("data-rml-source");
if (src)
{
Rml::String original = src->Get<Rml::String>();
Rml::String translated;
system_if->TranslateString(translated, original);
if (translated != text_elem->GetText())
text_elem->SetText(translated);
}
}
for (int i = 0; i < elem->GetNumChildren(true); i++)
ReTranslateElement(elem->GetChild(i), system_if);
}
void RmlManager::OnLanguageChanged()
{
if (!m_initialised || !m_context)
return;
app.DebugPrintf("[RmlManager] Re-translating all documents\n");
for (int i = 0; i < m_context->GetNumDocuments(); i++)
{
Rml::ElementDocument* doc = m_context->GetDocument(i);
if (doc)
ReTranslateElement(doc, m_system_interface.get());
}
}