This commit is contained in:
Mirco Wittrien 2021-04-14 14:58:24 +02:00
parent 5c60465d59
commit 7fa4213608
2 changed files with 13 additions and 3 deletions

View File

@ -602,8 +602,7 @@ module.exports = (_ => {
BDFDB.PluginUtils.translate = function (plugin) {
if (typeof plugin.setLabelsByLanguage == "function" || typeof plugin.changeLanguageStrings == "function") {
const translate = _ => {
const language = BDFDB.LanguageUtils.getLanguage();
if (typeof plugin.setLabelsByLanguage == "function") plugin.labels = plugin.setLabelsByLanguage(language.id);
if (typeof plugin.setLabelsByLanguage == "function") plugin.labels = plugin.setLabelsByLanguage();
if (typeof plugin.changeLanguageStrings == "function") plugin.changeLanguageStrings();
};
if (LibraryModules.LanguageStore.chosenLocale) translate();
@ -7898,6 +7897,17 @@ module.exports = (_ => {
if (!e.returnValue.props.children) LibraryModules.ContextMenuUtils.closeContextMenu();
}}, {priority: 10});
let languageChangeTimeout, translateAllNew = e => {
if (e.methodArguments[0] && e.methodArguments[0].locale) {
BDFDB.TimeUtils.clear(languageChangeTimeout);
languageChangeTimeout = BDFDB.TimeUtils.timeout(_ => {
for (let pluginName in PluginStores.loaded) if (PluginStores.loaded[pluginName].started) BDFDB.PluginUtils.translate(PluginStores.loaded[pluginName]);
BDFDB.PatchUtils.patch(this, LibraryModules.SettingsUtils, "updateLocalSettings", {after: translateAllNew});
}, 10000);
}
};
if (LibraryModules.SettingsUtils) BDFDB.PatchUtils.patch(this, LibraryModules.SettingsUtils, "updateLocalSettings", {after: translateAllNew});
InternalBDFDB.onSettingsClosed = function () {
if (InternalBDFDB.SettingsUpdated) {
delete InternalBDFDB.SettingsUpdated;

View File

@ -82,7 +82,7 @@ module.exports = (_ => {
};
}
onStart () {
onStart () {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SettingsUtils, "updateLocalSettings", {after: e => {
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].theme && settings.running) {
BDFDB.TimeUtils.clear(changeTimeout);