Add setting "gmst overrides l10n"

revert-6246b479
Petr Mikheev 2 years ago
parent 825d862f52
commit 718d5e4a71

@ -671,7 +671,8 @@ void OMW::Engine::prepareEngine()
mViewer->addEventHandler(mScreenCaptureHandler); mViewer->addEventHandler(mScreenCaptureHandler);
mL10nManager = std::make_unique<l10n::Manager>(mVFS.get()); 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); mEnvironment.setL10nManager(*mL10nManager);
mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs"); mLuaManager = std::make_unique<MWLua::LuaManager>(mVFS.get(), mResDir / "lua_libs");

@ -274,6 +274,7 @@ namespace MWGui
getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail"); getWidget(mWaterRainRippleDetail, "WaterRainRippleDetail");
getWidget(mPrimaryLanguage, "PrimaryLanguage"); getWidget(mPrimaryLanguage, "PrimaryLanguage");
getWidget(mSecondaryLanguage, "SecondaryLanguage"); getWidget(mSecondaryLanguage, "SecondaryLanguage");
getWidget(mGmstOverridesL10n, "GmstOverridesL10nButton");
getWidget(mWindowModeHint, "WindowModeHint"); getWidget(mWindowModeHint, "WindowModeHint");
getWidget(mLightingMethodButton, "LightingMethodButton"); getWidget(mLightingMethodButton, "LightingMethodButton");
getWidget(mLightsResetButton, "LightsResetButton"); getWidget(mLightsResetButton, "LightsResetButton");
@ -332,6 +333,8 @@ namespace MWGui
+= MyGUI::newDelegate(this, &SettingsWindow::onPrimaryLanguageChanged); += MyGUI::newDelegate(this, &SettingsWindow::onPrimaryLanguageChanged);
mSecondaryLanguage->eventComboChangePosition mSecondaryLanguage->eventComboChangePosition
+= MyGUI::newDelegate(this, &SettingsWindow::onSecondaryLanguageChanged); += MyGUI::newDelegate(this, &SettingsWindow::onSecondaryLanguageChanged);
mGmstOverridesL10n->eventMouseButtonClick
+= MyGUI::newDelegate(this, &SettingsWindow::onGmstOverridesL10nChanged);
computeMinimumWindowSize(); computeMinimumWindowSize();
@ -403,6 +406,8 @@ namespace MWGui
if (Misc::getFileExtension(path) == "yaml") if (Misc::getFileExtension(path) == "yaml")
{ {
std::string localeName(Misc::stemFile(path)); 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) if (std::find(availableLanguages.begin(), availableLanguages.end(), localeName)
== availableLanguages.end()) == availableLanguages.end())
availableLanguages.push_back(localeName); availableLanguages.push_back(localeName);
@ -571,6 +576,12 @@ namespace MWGui
Settings::Manager::setStringArray("preferred locales", "General", currentLocales); 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) void SettingsWindow::onVSyncModeChanged(MyGUI::ComboBox* _sender, size_t pos)
{ {
if (pos == MyGUI::ITEM_NONE) if (pos == MyGUI::ITEM_NONE)

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

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

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

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

@ -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. 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 log buffer size
--------------- ---------------

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

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

@ -55,6 +55,7 @@ ChangeRequiresRestart: "Ce changement requiert un redémarrage de l'application
Controller: "Manette" Controller: "Manette"
FieldOfView: "Champ de vision" FieldOfView: "Champ de vision"
FrameRateHint: "Note: Appuyez sur F3 pour afficher la fréquence d'affichage (FPS)." 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" InvertXAxis: "Inverser l'axe X"
Language: "Localisation" Language: "Localisation"
LanguageNote: "Note: Ce paramètre n'affecte pas les textes des fichiers ESM." LanguageNote: "Note: Ce paramètre n'affecte pas les textes des fichiers ESM."

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

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

@ -701,6 +701,16 @@
<UserString key="Caption_Text" value="#{OMWEngine:SecondaryLanguageTooltip}"/> <UserString key="Caption_Text" value="#{OMWEngine:SecondaryLanguageTooltip}"/>
</Widget> </Widget>
<Widget type="ComboBox" skin="MW_ComboBox" position="262 52 250 24" align="Left Top" name="SecondaryLanguage" /> <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> </Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="320 420 56 24" align="Right Bottom" name="OkButton"> <Widget type="AutoSizedButton" skin="MW_Button" position="320 420 56 24" align="Right Bottom" name="OkButton">

@ -393,6 +393,9 @@ notify on saved screenshot = false
# For example "de,en" means German as the first prority and English as a fallback. # For example "de,en" means German as the first prority and English as a fallback.
preferred locales = en 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. # Buffer size for the in-game log viewer (press F10 to toggle). Zero disables the log viewer.
log buffer size = 65536 log buffer size = 65536

Loading…
Cancel
Save