diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index f6a7032328..b66c8fb242 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -671,7 +671,8 @@ void OMW::Engine::prepareEngine() mViewer->addEventHandler(mScreenCaptureHandler); mL10nManager = std::make_unique(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(mVFS.get(), mResDir / "lua_libs"); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 76ef5c4cdb..8cfeb88aba 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -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) diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index d5c3bfac1f..ecf9bf0d94 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -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); diff --git a/components/l10n/manager.cpp b/components/l10n/manager.cpp index 333f1205c3..10cad81587 100644 --- a/components/l10n/manager.cpp +++ b/components/l10n/manager.cpp @@ -9,10 +9,11 @@ namespace l10n { - void Manager::setPreferredLocales(const std::vector& langs) + void Manager::setPreferredLocales(const std::vector& langs, bool gmstHasPriority) { mPreferredLocales.clear(); - mPreferredLocales.push_back(icu::Locale("gmst")); + if (gmstHasPriority) + mPreferredLocales.push_back(icu::Locale("gmst")); std::set 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:"; diff --git a/components/l10n/manager.hpp b/components/l10n/manager.hpp index ca2ebecebf..2ee54921b3 100644 --- a/components/l10n/manager.hpp +++ b/components/l10n/manager.hpp @@ -22,7 +22,7 @@ namespace l10n } void dropCache() { mCache.clear(); } - void setPreferredLocales(const std::vector& locales); + void setPreferredLocales(const std::vector& locales, bool gmstHasPriority = true); const std::vector& getPreferredLocales() const { return mPreferredLocales; } void setGmstLoader(std::function fn) { mGmstLoader = std::move(fn); } diff --git a/components/settings/categories/general.hpp b/components/settings/categories/general.hpp index d6a0f267a9..94f6848798 100644 --- a/components/settings/categories/general.hpp +++ b/components/settings/categories/general.hpp @@ -29,6 +29,7 @@ namespace Settings makeEnumSanitizerString({ "none", "nearest", "linear" }) }; SettingValue mNotifyOnSavedScreenshot{ mIndex, "General", "notify on saved screenshot" }; SettingValue mPreferredLocales{ mIndex, "General", "preferred locales" }; + SettingValue mGmstOverridesL10n{ mIndex, "General", "gmst overrides l10n" }; SettingValue mLogBufferSize{ mIndex, "General", "log buffer size" }; SettingValue mConsoleHistoryBufferSize{ mIndex, "General", "console history buffer size" }; }; diff --git a/docs/source/reference/modding/settings/general.rst b/docs/source/reference/modding/settings/general.rst index 514c9c6d31..e56b84ab89 100644 --- a/docs/source/reference/modding/settings/general.rst +++ b/docs/source/reference/modding/settings/general.rst @@ -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 --------------- diff --git a/files/data/l10n/OMWEngine/de.yaml b/files/data/l10n/OMWEngine/de.yaml index 9609935669..f2b4ee7e5a 100644 --- a/files/data/l10n/OMWEngine/de.yaml +++ b/files/data/l10n/OMWEngine/de.yaml @@ -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" diff --git a/files/data/l10n/OMWEngine/en.yaml b/files/data/l10n/OMWEngine/en.yaml index a44c8c0224..08df886f18 100644 --- a/files/data/l10n/OMWEngine/en.yaml +++ b/files/data/l10n/OMWEngine/en.yaml @@ -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" diff --git a/files/data/l10n/OMWEngine/fr.yaml b/files/data/l10n/OMWEngine/fr.yaml index eed56950b0..5955318bee 100644 --- a/files/data/l10n/OMWEngine/fr.yaml +++ b/files/data/l10n/OMWEngine/fr.yaml @@ -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." diff --git a/files/data/l10n/OMWEngine/ru.yaml b/files/data/l10n/OMWEngine/ru.yaml index e132bffa87..5a6043d578 100644 --- a/files/data/l10n/OMWEngine/ru.yaml +++ b/files/data/l10n/OMWEngine/ru.yaml @@ -77,6 +77,7 @@ FrameRateHint: "Подсказка: нажмите F3, чтобы показат GammaCorrection: "Гамма-коррекция" GammaDark: "Темно" GammaLight: "Светло" +GmstOverridesL10n: "Строки из ESM-файлов имеют максимальный приоритет" InvertXAxis: "Инвертировать ось X" InvertYAxis: "Инвертировать ось Y" Language: "Язык" diff --git a/files/data/l10n/OMWEngine/sv.yaml b/files/data/l10n/OMWEngine/sv.yaml index 7c873bd436..2adc15371d 100644 --- a/files/data/l10n/OMWEngine/sv.yaml +++ b/files/data/l10n/OMWEngine/sv.yaml @@ -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" diff --git a/files/data/mygui/openmw_settings_window.layout b/files/data/mygui/openmw_settings_window.layout index b846a7884f..e912ababfd 100644 --- a/files/data/mygui/openmw_settings_window.layout +++ b/files/data/mygui/openmw_settings_window.layout @@ -701,6 +701,16 @@ + + + + + + + + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 8196766db1..40c1ae7ff4 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -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