mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
100% cover all texts
100% cover all texts
This commit is contained in:
@@ -15,7 +15,7 @@ from gradio_client.serializing import ImgSerializable
|
||||
from PIL import Image as _Image # using _ to minimize namespace pollution
|
||||
|
||||
from gradio import processing_utils, utils
|
||||
from gradio.components.base import IOComponent, _Keywords
|
||||
from gradio.components.base import IOComponent, _Keywords, Block
|
||||
from gradio.deprecation import warn_style_method_deprecation
|
||||
from gradio.events import (
|
||||
Changeable,
|
||||
@@ -450,14 +450,14 @@ class Image(
|
||||
|
||||
all_components = []
|
||||
|
||||
if not hasattr(IOComponent, 'original__init__'):
|
||||
IOComponent.original_init = IOComponent.__init__
|
||||
if not hasattr(Block, 'original__init__'):
|
||||
Block.original_init = Block.__init__
|
||||
|
||||
|
||||
def ioc_ini(self, *args, **kwargs):
|
||||
def blk_ini(self, *args, **kwargs):
|
||||
all_components.append(self)
|
||||
return IOComponent.original_init(self, *args, **kwargs)
|
||||
return Block.original_init(self, *args, **kwargs)
|
||||
|
||||
|
||||
IOComponent.__init__ = ioc_ini
|
||||
Block.__init__ = blk_ini
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ def localization_js(filename):
|
||||
print(str(e))
|
||||
print(f'Failed to load localization file {full_name}')
|
||||
|
||||
# data = {k: 'XXX' for k in data.keys()} # use this to see if all texts are covered
|
||||
|
||||
return f"window.localization = {json.dumps(data)}"
|
||||
|
||||
|
||||
@@ -29,11 +31,14 @@ 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):
|
||||
@@ -45,7 +50,7 @@ def dump_english_config(components):
|
||||
if isinstance(y, str):
|
||||
all_texts.append(y)
|
||||
|
||||
config_dict = {k: k for k in all_texts if k != ""}
|
||||
config_dict = {k: k for k in all_texts if k != "" and 'progress-container' not in k}
|
||||
full_name = os.path.abspath(os.path.join(localization_root, 'en.json'))
|
||||
|
||||
with open(full_name, "w", encoding="utf-8") as json_file:
|
||||
|
||||
Reference in New Issue
Block a user