mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
Added language/en.json to make translation easier.
Added language/en.json to make translation easier.
This commit is contained in:
@@ -446,3 +446,18 @@ class Image(
|
||||
): # If an externally hosted image, don't convert to absolute path
|
||||
return input_data
|
||||
return str(utils.abspath(input_data))
|
||||
|
||||
|
||||
all_components = []
|
||||
|
||||
if not hasattr(IOComponent, 'original__init__'):
|
||||
IOComponent.original_init = IOComponent.__init__
|
||||
|
||||
|
||||
def ioc_ini(self, *args, **kwargs):
|
||||
all_components.append(self)
|
||||
return IOComponent.original_init(self, *args, **kwargs)
|
||||
|
||||
|
||||
IOComponent.__init__ = ioc_ini
|
||||
|
||||
|
||||
@@ -23,3 +23,35 @@ def localization_js(filename):
|
||||
print(f'Failed to load localization file {full_name}')
|
||||
|
||||
return f"window.localization = {json.dumps(data)}"
|
||||
|
||||
|
||||
def dump_english_config(components):
|
||||
all_texts = []
|
||||
for c in components:
|
||||
label = getattr(c, 'label', None)
|
||||
# value = getattr(c, 'value', None)
|
||||
choices = getattr(c, 'choices', None)
|
||||
info = getattr(c, 'info', None)
|
||||
|
||||
if isinstance(label, str):
|
||||
all_texts.append(label)
|
||||
# if isinstance(value, str):
|
||||
# all_texts.append(value)
|
||||
if isinstance(info, str):
|
||||
all_texts.append(info)
|
||||
if isinstance(choices, list):
|
||||
for x in choices:
|
||||
if isinstance(x, str):
|
||||
all_texts.append(x)
|
||||
if isinstance(x, tuple):
|
||||
for y in x:
|
||||
if isinstance(y, str):
|
||||
all_texts.append(y)
|
||||
|
||||
config_dict = {k: k for k in all_texts}
|
||||
full_name = os.path.abspath(os.path.join(localization_root, 'en.json'))
|
||||
|
||||
with open(full_name, "w", encoding="utf-8") as json_file:
|
||||
json.dump(config_dict, json_file, indent=4)
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user