From 4e7f67812edd688f30e54f48517b3e16c5887553 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 29 Jul 2024 02:30:41 +0200 Subject: feat: improve modules translation --- include/GFModuleCommonUtils.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/GFModuleCommonUtils.hpp b/include/GFModuleCommonUtils.hpp index 2e18cc5..0c29dc7 100644 --- a/include/GFModuleCommonUtils.hpp +++ b/include/GFModuleCommonUtils.hpp @@ -45,6 +45,17 @@ #define LISTEN(event) GFModuleListenEvent(GFGetModuleID(), DUP(event)) +#define LOAD_TRANS(name) \ + { \ + QFile f(QString(":/i18n/%2.%1.qm").arg(GFAppActiveLocale()).arg(name)); \ + if (f.exists() && f.open(QIODevice::ReadOnly)) { \ + FLOG_INFO("%3 loading, locale: %1, path: %2", GFAppActiveLocale(), \ + f.fileName(), UDUP(GFGetModuleID())); \ + auto b = f.readAll(); \ + GFAppRegisterTranslator(AllocBufferAndCopy(b), b.size()); \ + } \ + } + #define EXECUTE_MODULE() \ auto GFExecuteModule(GFModuleEvent* p_event) -> int { \ auto event = ConvertEventToMap(p_event); -- cgit v1.2.3