1
0
forked from mirrors/0ad

Remove "useLongStrings" logic

As it turns out we don't need that special logic for handling the "long"
locale properly and everything continues to work as before without it.

The only difference is that the number format not being the one from
en_us anymore when using the "long" locale, but the one of the
system-wide configured language, which should be an even better user
experience than before.
This commit is contained in:
Dunedan
2025-02-20 16:17:15 +01:00
parent c475cc2265
commit 75d343293f
4 changed files with 9 additions and 65 deletions
+7 -37
View File
@@ -170,11 +170,6 @@ const icu::Locale& L10n::GetCurrentLocale() const
bool L10n::SaveLocale(const std::string& localeCode) const
{
if (localeCode == "long" && InDevelopmentCopy())
{
g_ConfigDB.SetValueString(CFG_USER, "locale", "long");
return true;
}
return SaveLocale(icu::Locale(icu::Locale::createCanonical(localeCode.c_str())));
}
@@ -290,19 +285,9 @@ void L10n::ReevaluateCurrentLocaleAndReload()
std::string locale;
CFG_GET_VAL("locale", locale);
if (locale == "long")
{
// Set ICU to en_US to have a valid language for displaying dates
m_CurrentLocale = icu::Locale::getUS();
m_CurrentLocaleIsOriginalGameLocale = false;
m_UseLongStrings = true;
}
else
{
GetDictionaryLocale(locale, m_CurrentLocale);
m_CurrentLocaleIsOriginalGameLocale = (m_CurrentLocale == icu::Locale::getUS()) == 1;
m_UseLongStrings = false;
}
GetDictionaryLocale(locale, m_CurrentLocale);
m_CurrentLocaleIsOriginalGameLocale = (m_CurrentLocale == icu::Locale::getUS()) == 1;
LoadDictionaryForCurrentLocale();
}
@@ -318,11 +303,6 @@ std::vector<std::string> L10n::GetAllLocales() const
}
bool L10n::UseLongStrings() const
{
return m_UseLongStrings;
};
std::vector<std::string> L10n::GetSupportedLocaleBaseNames() const
{
std::vector<std::string> supportedLocaleCodes;
@@ -532,8 +512,6 @@ Status L10n::ReloadChangedFile(const VfsPath& path)
return INFO::OK;
std::wstring dictName = GetFallbackToAvailableDictLocale(m_CurrentLocale);
if (m_UseLongStrings)
dictName = L"long";
if (dictName.empty())
return INFO::OK;
@@ -564,19 +542,11 @@ void L10n::LoadDictionaryForCurrentLocale()
m_Dictionary = std::make_unique<tinygettext::Dictionary>();
VfsPaths filenames;
if (m_UseLongStrings)
std::wstring dictName = GetFallbackToAvailableDictLocale(m_CurrentLocale);
if (vfs::GetPathnames(g_VFS, L"l10n/", dictName.append(L".*.po").c_str(), filenames) < 0)
{
if (vfs::GetPathnames(g_VFS, L"l10n/", L"long.*.po", filenames) < 0)
return;
}
else
{
std::wstring dictName = GetFallbackToAvailableDictLocale(m_CurrentLocale);
if (vfs::GetPathnames(g_VFS, L"l10n/", dictName.append(L".*.po").c_str(), filenames) < 0)
{
LOGERROR("No files for the dictionary found, but at this point the input should already be validated!");
return;
}
LOGERROR("No files for the dictionary found, but at this point the input should already be validated!");
return;
}
for (const VfsPath& path : filenames)
-17
View File
@@ -210,15 +210,6 @@ public:
*/
std::string GetLocaleScript(const std::string& locale) const;
/**
* Returns @c true if the current locale is the special "Long Strings"
* locale. It returns @c false otherwise.
*
* @return Whether the current locale is the special "Long Strings"
* (@c true) or not (@c false).
*/
bool UseLongStrings() const;
/**
* Returns an array of paths to files in the virtual filesystem that provide
* translations for the specified locale code.
@@ -523,14 +514,6 @@ private:
*/
bool m_CurrentLocaleIsOriginalGameLocale{false};
/**
* Whether the game is using the special game locale with the longest
* strings of each translation (@c true) or not (@c false).
*
* @sa https://gitea.wildfiregames.com/0ad/0ad/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale
*/
bool m_UseLongStrings{false};
/**
* Loads the translation files for the
* @link L10n::GetCurrentLocale() current locale@endlink.
@@ -84,7 +84,6 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
REGISTER_L10N_FUNC(static_cast<std::string(L10n::*)(const std::string&) const>(&L10n::GetDictionaryLocale), "GetDictionaryLocale");
REGISTER_L10N(GetDictionariesForLocale)
REGISTER_L10N(UseLongStrings)
REGISTER_L10N(GetLocaleLanguage)
REGISTER_L10N(GetLocaleBaseName)
REGISTER_L10N(GetLocaleCountry)