diff options
author | Petr Mikheev <ptmikheev@gmail.com> | 2022-01-05 19:50:52 +0100 |
---|---|---|
committer | Petr Mikheev <ptmikheev@gmail.com> | 2022-01-05 19:50:52 +0100 |
commit | 5eca122f0424b5194715c0b086fd37dd7298f8d5 (patch) | |
tree | 4fcc747921d39b1fcf93d977230cc6908fa79e70 | |
parent | b56406b0addb124f9e369198a54f8510cd146a2f (diff) |
Avoid creating multiple i18n contexts with the same name.
-rw-r--r-- | components/lua/i18n.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/components/lua/i18n.cpp b/components/lua/i18n.cpp index 9fd2724f75..e4d8e3ba78 100644 --- a/components/lua/i18n.cpp +++ b/components/lua/i18n.cpp @@ -99,6 +99,9 @@ namespace LuaUtil { if (mI18nLoader == sol::nil) throw std::runtime_error("LuaUtil::I18nManager is not initialized"); + auto it = mContexts.find(contextName); + if (it != mContexts.end()) + return sol::make_object(mLua->sol(), it->second); Context ctx{contextName, mLua->newTable(), call(mI18nLoader, "i18n.init")}; ctx.updateLang(this); mContexts.emplace(contextName, ctx); |