1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-31 15:32:45 +00:00

Add setting "gmst overrides l10n"

This commit is contained in:
Petr Mikheev 2023-06-13 09:48:40 +02:00
parent 825d862f52
commit 718d5e4a71
14 changed files with 53 additions and 4 deletions

View File

@ -671,7 +671,8 @@ void OMW::Engine::prepareEngine()
mViewer->addEventHandler(mScreenCaptureHandler);
mL10nManager = std::make_unique<l10n::Manager>(mVFS.get());
mL10nManager->setPreferredLocales(Settings::Manager::getStringArray("preferred locales", "General"));
mL10nManager->setPreferredLocales(Settings::Manager::getStringArray("preferred locales", "General"),
Settings::Manager::getBool("gmst overrides l10n", "General"));
mEnvironment.setL10nManager(*mL10nManager);
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");

View File

@ -274,6 +274,7 @@ namespace MWGui
getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail");
getWidget(mPrimaryLanguage, "PrimaryLanguage");
getWidget(mSecondaryLanguage, "SecondaryLanguage");
getWidget(mGmstOverridesL10n, "GmstOverridesL10nButton");
getWidget(mWindowModeHint, "WindowModeHint");
getWidget(mLightingMethodButton, "LightingMethodButton");
getWidget(mLightsResetButton, "LightsResetButton");
@ -332,6 +333,8 @@ namespace MWGui
+= MyGUI::newDelegate(this, &SettingsWindow::onPrimaryLanguageChanged);
mSecondaryLanguage->eventComboChangePosition
+= MyGUI::newDelegate(this, &SettingsWindow::onSecondaryLanguageChanged);
mGmstOverridesL10n->eventMouseButtonClick
+= MyGUI::newDelegate(this, &SettingsWindow::onGmstOverridesL10nChanged);
computeMinimumWindowSize();
@ -403,6 +406,8 @@ namespace MWGui
if (Misc::getFileExtension(path) == "yaml")
{
std::string localeName(Misc::stemFile(path));
if (localeName == "gmst")
continue; // fake locale to get gmst strings from content files
if (std::find(availableLanguages.begin(), availableLanguages.end(), localeName)
== availableLanguages.end())
availableLanguages.push_back(localeName);
@ -571,6 +576,12 @@ namespace MWGui
Settings::Manager::setStringArray("preferred locales", "General", currentLocales);
}
void SettingsWindow::onGmstOverridesL10nChanged(MyGUI::Widget*)
{
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(
"#{OMWEngine:ChangeRequiresRestart}", { "#{Interface:OK}" }, true);
}
void SettingsWindow::onVSyncModeChanged(MyGUI::ComboBox* _sender, size_t pos)
{
if (pos == MyGUI::ITEM_NONE)

View File

@ -45,6 +45,7 @@ namespace MWGui
MyGUI::ComboBox* mPrimaryLanguage;
MyGUI::ComboBox* mSecondaryLanguage;
MyGUI::Button* mGmstOverridesL10n;
MyGUI::Widget* mWindowModeHint;
@ -84,6 +85,7 @@ namespace MWGui
void onPrimaryLanguageChanged(MyGUI::ComboBox* _sender, size_t pos) { onLanguageChanged(0, _sender, pos); }
void onSecondaryLanguageChanged(MyGUI::ComboBox* _sender, size_t pos) { onLanguageChanged(1, _sender, pos); }
void onLanguageChanged(size_t langPriority, MyGUI::ComboBox* _sender, size_t pos);
void onGmstOverridesL10nChanged(MyGUI::Widget* _sender);
void onWindowModeChanged(MyGUI::ComboBox* _sender, size_t pos);
void onVSyncModeChanged(MyGUI::ComboBox* _sender, size_t pos);

View File

@ -9,10 +9,11 @@
namespace l10n
{
void Manager::setPreferredLocales(const std::vector<std::string>& langs)
void Manager::setPreferredLocales(const std::vector<std::string>& langs, bool gmstHasPriority)
{
mPreferredLocales.clear();
mPreferredLocales.push_back(icu::Locale("gmst"));
if (gmstHasPriority)
mPreferredLocales.push_back(icu::Locale("gmst"));
std::set<std::string> langSet;
for (const auto& lang : langs)
{
@ -21,6 +22,8 @@ namespace l10n
langSet.insert(lang);
mPreferredLocales.push_back(icu::Locale(lang.c_str()));
}
if (!gmstHasPriority)
mPreferredLocales.push_back(icu::Locale("gmst"));
{
Log msg(Debug::Info);
msg << "Preferred locales:";

View File

@ -22,7 +22,7 @@ namespace l10n
}
void dropCache() { mCache.clear(); }
void setPreferredLocales(const std::vector<std::string>& locales);
void setPreferredLocales(const std::vector<std::string>& locales, bool gmstHasPriority = true);
const std::vector<icu::Locale>& getPreferredLocales() const { return mPreferredLocales; }
void setGmstLoader(std::function<std::string(std::string_view)> fn) { mGmstLoader = std::move(fn); }

View File

@ -29,6 +29,7 @@ namespace Settings
makeEnumSanitizerString({ "none", "nearest", "linear" }) };
SettingValue<bool> mNotifyOnSavedScreenshot{ mIndex, "General", "notify on saved screenshot" };
SettingValue<std::string> mPreferredLocales{ mIndex, "General", "preferred locales" };
SettingValue<bool> mGmstOverridesL10n{ mIndex, "General", "gmst overrides l10n" };
SettingValue<std::size_t> mLogBufferSize{ mIndex, "General", "log buffer size" };
SettingValue<std::size_t> mConsoleHistoryBufferSize{ mIndex, "General", "console history buffer size" };
};

View File

@ -87,6 +87,19 @@ refer to any of the country-specific variants.
Two highest priority locales may be assigned via the Localization tab of the in-game options.
gmst overrides l10n
-------------------
:Type: boolean
:Range: True/False
:Default: True
If true, localization GMSTs in content have priority over l10n files.
Setting to false can be useful if selected preferred locale doesn't
match the language of content files.
Can be changed via the Localization tab of the in-game options.
log buffer size
---------------

View File

@ -140,6 +140,7 @@ WindowModeWindowedFullscreen: "Fenster Vollbild"
#GammaCorrection: "Gamma Correction"
#GammaDark: "Dark"
#GammaLight: "Light"
#GmstOverridesL10n: "Strings from ESM files have priority"
#InvertYAxis: "Invert Y Axis"
#MenuHelpDelay: "Menu Help Delay"
#MenuTransparency: "Menu Transparency"

View File

@ -77,6 +77,7 @@ FrameRateHint: "Hint: press F3 to show\nthe current frame rate."
GammaCorrection: "Gamma Correction"
GammaDark: "Dark"
GammaLight: "Light"
GmstOverridesL10n: "Strings from ESM files have priority"
InvertXAxis: "Invert X Axis"
InvertYAxis: "Invert Y Axis"
Language: "Language"

View File

@ -55,6 +55,7 @@ ChangeRequiresRestart: "Ce changement requiert un redémarrage de l'application
Controller: "Manette"
FieldOfView: "Champ de vision"
FrameRateHint: "Note: Appuyez sur F3 pour afficher la fréquence d'affichage (FPS)."
#GmstOverridesL10n: "Strings from ESM files have priority" to be translated
InvertXAxis: "Inverser l'axe X"
Language: "Localisation"
LanguageNote: "Note: Ce paramètre n'affecte pas les textes des fichiers ESM."

View File

@ -77,6 +77,7 @@ FrameRateHint: "Подсказка: нажмите F3, чтобы показат
GammaCorrection: "Гамма-коррекция"
GammaDark: "Темно"
GammaLight: "Светло"
GmstOverridesL10n: "Строки из ESM-файлов имеют максимальный приоритет"
InvertXAxis: "Инвертировать ось X"
InvertYAxis: "Инвертировать ось Y"
Language: "Язык"

View File

@ -143,6 +143,7 @@ WindowModeWindowedFullscreen: "Fullskärm i fönsterläge"
#GammaCorrection: "Gamma Correction"
#GammaDark: "Dark"
#GammaLight: "Light"
#GmstOverridesL10n: "Strings from ESM files have priority"
#InvertYAxis: "Invert Y Axis"
#MenuHelpDelay: "Menu Help Delay"
#MenuTransparency: "Menu Transparency"

View File

@ -701,6 +701,16 @@
<UserString key="Caption_Text" value="#{OMWEngine:SecondaryLanguageTooltip}"/>
</Widget>
<Widget type="ComboBox" skin="MW_ComboBox" position="262 52 250 24" align="Left Top" name="SecondaryLanguage" />
<Widget type="HBox" position="4 84 500 32">
<Widget type="AutoSizedButton" skin="MW_Button" name="GmstOverridesL10nButton">
<UserString key="SettingCategory" value="General"/>
<UserString key="SettingName" value="gmst overrides l10n"/>
<UserString key="SettingType" value="CheckButton"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText">
<Property key="Caption" value="#{OMWEngine:GmstOverridesL10n} "/>
</Widget>
</Widget>
</Widget>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="320 420 56 24" align="Right Bottom" name="OkButton">

View File

@ -393,6 +393,9 @@ notify on saved screenshot = false
# For example "de,en" means German as the first prority and English as a fallback.
preferred locales = en
# If true then l10n/*/gmst.yaml has priority over other l10n files.
gmst overrides l10n = true
# Buffer size for the in-game log viewer (press F10 to toggle). Zero disables the log viewer.
log buffer size = 65536