mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Merge branch 'duplicated_locales' into 'master'
Ignore duplicated preferred l10n locales See merge request OpenMW/openmw!2796
This commit is contained in:
commit
a91b4e0cce
@ -94,7 +94,6 @@ you_have_arrows: "Arrows count: {count}"
|
|||||||
internal::CaptureStdout();
|
internal::CaptureStdout();
|
||||||
l.safe_script("t1 = l10n('Test1')");
|
l.safe_script("t1 = l10n('Test1')");
|
||||||
EXPECT_THAT(internal::GetCapturedStdout(),
|
EXPECT_THAT(internal::GetCapturedStdout(),
|
||||||
"Fallback locale: en\n"
|
|
||||||
"Language file \"l10n/Test1/de.yaml\" is enabled\n"
|
"Language file \"l10n/Test1/de.yaml\" is enabled\n"
|
||||||
"Language file \"l10n/Test1/en.yaml\" is enabled\n");
|
"Language file \"l10n/Test1/en.yaml\" is enabled\n");
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "manager.hpp"
|
#include "manager.hpp"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <unicode/errorcode.h>
|
#include <unicode/errorcode.h>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
@ -11,8 +12,14 @@ namespace l10n
|
|||||||
void Manager::setPreferredLocales(const std::vector<std::string>& langs)
|
void Manager::setPreferredLocales(const std::vector<std::string>& langs)
|
||||||
{
|
{
|
||||||
mPreferredLocales.clear();
|
mPreferredLocales.clear();
|
||||||
|
std::set<std::string> langSet;
|
||||||
for (const auto& lang : langs)
|
for (const auto& lang : langs)
|
||||||
|
{
|
||||||
|
if (langSet.contains(lang))
|
||||||
|
continue;
|
||||||
|
langSet.insert(lang);
|
||||||
mPreferredLocales.push_back(icu::Locale(lang.c_str()));
|
mPreferredLocales.push_back(icu::Locale(lang.c_str()));
|
||||||
|
}
|
||||||
{
|
{
|
||||||
Log msg(Debug::Info);
|
Log msg(Debug::Info);
|
||||||
msg << "Preferred locales:";
|
msg << "Preferred locales:";
|
||||||
@ -83,10 +90,6 @@ namespace l10n
|
|||||||
throw std::runtime_error(std::string("Invalid l10n context name: ") + contextName);
|
throw std::runtime_error(std::string("Invalid l10n context name: ") + contextName);
|
||||||
icu::Locale fallbackLocale(fallbackLocaleName.c_str());
|
icu::Locale fallbackLocale(fallbackLocaleName.c_str());
|
||||||
std::shared_ptr<MessageBundles> ctx = std::make_shared<MessageBundles>(mPreferredLocales, fallbackLocale);
|
std::shared_ptr<MessageBundles> ctx = std::make_shared<MessageBundles>(mPreferredLocales, fallbackLocale);
|
||||||
{
|
|
||||||
Log msg(Debug::Verbose);
|
|
||||||
msg << "Fallback locale: " << fallbackLocale.getName();
|
|
||||||
}
|
|
||||||
updateContext(contextName, *ctx);
|
updateContext(contextName, *ctx);
|
||||||
mCache.emplace(key, ctx);
|
mCache.emplace(key, ctx);
|
||||||
return ctx;
|
return ctx;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user