aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-09-30 09:47:52 +0300
committerGitHub <noreply@github.com>2023-09-30 09:47:52 +0300
commit3aa9f01bdc04d3afc18d6a9cf1a3abb2ca9d9d83 (patch)
tree27ab6089c45ca336601c98bd95f0d71132b3069b /modules
parent4e5d2526cb2596cd7bff332c002aa4d2f119fcf5 (diff)
parent413123f08a745e9417fd384d2c1bee1e0e5e5730 (diff)
Merge pull request #13077 from sdwebui-extensions/master
fix localization when there are multi same localization file in the extensions
Diffstat (limited to 'modules')
-rw-r--r--modules/localization.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/modules/localization.py b/modules/localization.py
index c1320288..108f792e 100644
--- a/modules/localization.py
+++ b/modules/localization.py
@@ -14,21 +14,24 @@ def list_localizations(dirname):
if ext.lower() != ".json":
continue
- localizations[fn] = os.path.join(dirname, file)
+ localizations[fn] = [os.path.join(dirname, file)]
for file in scripts.list_scripts("localizations", ".json"):
fn, ext = os.path.splitext(file.filename)
- localizations[fn] = file.path
+ if fn not in localizations:
+ localizations[fn] = []
+ localizations[fn].append(file.path)
def localization_js(current_localization_name: str) -> str:
- fn = localizations.get(current_localization_name, None)
+ fns = localizations.get(current_localization_name, None)
data = {}
- if fn is not None:
- try:
- with open(fn, "r", encoding="utf8") as file:
- data = json.load(file)
- except Exception:
- errors.report(f"Error loading localization from {fn}", exc_info=True)
+ if fns is not None:
+ for fn in fns:
+ try:
+ with open(fn, "r", encoding="utf8") as file:
+ data.update(json.load(file))
+ except Exception:
+ errors.report(f"Error loading localization from {fn}", exc_info=True)
return f"window.localization = {json.dumps(data)}"