mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #13077 from sdwebui-extensions/master
fix localization when there are multi same localization file in the extensions
This commit is contained in:
commit
3aa9f01bdc
@ -14,21 +14,24 @@ def list_localizations(dirname):
|
|||||||
if ext.lower() != ".json":
|
if ext.lower() != ".json":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
localizations[fn] = os.path.join(dirname, file)
|
localizations[fn] = [os.path.join(dirname, file)]
|
||||||
|
|
||||||
for file in scripts.list_scripts("localizations", ".json"):
|
for file in scripts.list_scripts("localizations", ".json"):
|
||||||
fn, ext = os.path.splitext(file.filename)
|
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:
|
def localization_js(current_localization_name: str) -> str:
|
||||||
fn = localizations.get(current_localization_name, None)
|
fns = localizations.get(current_localization_name, None)
|
||||||
data = {}
|
data = {}
|
||||||
if fn is not None:
|
if fns is not None:
|
||||||
try:
|
for fn in fns:
|
||||||
with open(fn, "r", encoding="utf8") as file:
|
try:
|
||||||
data = json.load(file)
|
with open(fn, "r", encoding="utf8") as file:
|
||||||
except Exception:
|
data.update(json.load(file))
|
||||||
errors.report(f"Error loading localization from {fn}", exc_info=True)
|
except Exception:
|
||||||
|
errors.report(f"Error loading localization from {fn}", exc_info=True)
|
||||||
|
|
||||||
return f"window.localization = {json.dumps(data)}"
|
return f"window.localization = {json.dumps(data)}"
|
||||||
|
Loading…
Reference in New Issue
Block a user