Commit 3aa9f01b authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #13077 from sdwebui-extensions/master

fix localization when there are multi same localization file in the extensions
parents 4e5d2526 413123f0
......@@ -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)}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment