From 7fa42136086f35d4cd3686c3d4a63f95e4cdea1e Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 14 Apr 2021 14:58:24 +0200 Subject: [PATCH] stuff --- Library/0BDFDB.plugin.js | 14 ++++++++++++-- .../TimedLightDarkMode.plugin.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index e45263afc1..78fe037e8a 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -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; diff --git a/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js b/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js index b9fc9a0f7a..933df00072 100644 --- a/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js +++ b/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js @@ -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);