Index: source/i18n/L10n.h =================================================================== --- source/i18n/L10n.h +++ source/i18n/L10n.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -517,7 +517,7 @@ * @sa GetSupportedLocaleBaseNames() * @sa GetSupportedLocaleDisplayNames() */ - std::vector> availableLocales; + std::vector availableLocales; /** * Whether the game is using the default game locale (@c true), 'en_US', or Index: source/i18n/L10n.cpp =================================================================== --- source/i18n/L10n.cpp +++ source/i18n/L10n.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -192,9 +192,9 @@ { std::wstringstream stream; - auto checkLangAndCountry = [&locale](const std::unique_ptr& l) { - return strcmp(locale.getLanguage(), l->getLanguage()) == 0 - && strcmp(locale.getCountry(), l->getCountry()) == 0; + auto checkLangAndCountry = [&locale](const icu::Locale& l) { + return strcmp(locale.getLanguage(), l.getLanguage()) == 0 + && strcmp(locale.getCountry(), l.getCountry()) == 0; }; if (strcmp(locale.getCountry(), "") != 0 @@ -204,8 +204,8 @@ return stream.str(); } - auto checkLang = [&locale](const std::unique_ptr& l) { - return strcmp(locale.getLanguage(), l->getLanguage()) == 0; + auto checkLang = [&locale](const icu::Locale& l) { + return strcmp(locale.getLanguage(), l.getLanguage()) == 0; }; if (std::find_if(availableLocales.begin(), availableLocales.end(), checkLang) != availableLocales.end()) @@ -288,11 +288,11 @@ std::vector L10n::GetSupportedLocaleBaseNames() const { std::vector supportedLocaleCodes; - for (const std::unique_ptr& locale : availableLocales) + for (const icu::Locale& locale : availableLocales) { - if (!InDevelopmentCopy() && strcmp(locale->getBaseName(), "long") == 0) + if (!InDevelopmentCopy() && strcmp(locale.getBaseName(), "long") == 0) continue; - supportedLocaleCodes.push_back(locale->getBaseName()); + supportedLocaleCodes.push_back(locale.getBaseName()); } return supportedLocaleCodes; } @@ -300,9 +300,9 @@ std::vector L10n::GetSupportedLocaleDisplayNames() const { std::vector supportedLocaleDisplayNames; - for (const std::unique_ptr& locale : availableLocales) + for (const icu::Locale& locale : availableLocales) { - if (strcmp(locale->getBaseName(), "long") == 0) + if (strcmp(locale.getBaseName(), "long") == 0) { if (InDevelopmentCopy()) supportedLocaleDisplayNames.push_back(wstring_from_utf8(Translate("Long strings"))); @@ -310,7 +310,7 @@ } icu::UnicodeString utf16LocaleDisplayName; - locale->getDisplayName(*locale, utf16LocaleDisplayName); + locale.getDisplayName(locale, utf16LocaleDisplayName); char localeDisplayName[512]; icu::CheckedArrayByteSink sink(localeDisplayName, ARRAY_SIZE(localeDisplayName)); utf16LocaleDisplayName.toUTF8(sink); @@ -556,7 +556,7 @@ availableLocales.clear(); // US is always available. - availableLocales.emplace_back(new icu::Locale(icu::Locale::getUS())); + availableLocales.push_back(icu::Locale::getUS()); VfsPaths filenames; if (vfs::GetPathnames(g_VFS, L"l10n/", L"*.po", filenames) < 0) @@ -568,10 +568,8 @@ std::string filename = utf8_from_wstring(path.string()).substr(strlen("l10n/")); size_t lengthToFirstDot = filename.find('.'); std::string localeCode = filename.substr(0, lengthToFirstDot); - std::unique_ptr locale = std::make_unique(icu::Locale::createCanonical(localeCode.c_str())); - auto it = std::find_if(availableLocales.begin(), availableLocales.end(), [&locale](const std::unique_ptr& l) { - return *locale == *l; - }); + icu::Locale locale(icu::Locale::createCanonical(localeCode.c_str())); + const auto it = std::find(availableLocales.begin(), availableLocales.end(), locale); if (it != availableLocales.end()) continue;