From 82b415c9c141d8616e1e9ccb55e47a1884d652ba Mon Sep 17 00:00:00 2001 From: daxijiu <127850313+daxijiu@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:03:49 +0800 Subject: fix some content are ignore by localization in setting "Face restoration model" and "Select which Real-ESRGAN models" and in extras "upscaler 1 & 2" are ignore by localization --- javascript/localization.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'javascript/localization.js') diff --git a/javascript/localization.js b/javascript/localization.js index eb22b8a7..0c9032f9 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -11,11 +11,11 @@ var ignore_ids_for_localization = { train_hypernetwork: 'OPTION', txt2img_styles: 'OPTION', img2img_styles: 'OPTION', - setting_random_artist_categories: 'SPAN', - setting_face_restoration_model: 'SPAN', - setting_realesrgan_enabled_models: 'SPAN', - extras_upscaler_1: 'SPAN', - extras_upscaler_2: 'SPAN', + setting_random_artist_categories: 'OPTION', + setting_face_restoration_model: 'OPTION', + setting_realesrgan_enabled_models: 'OPTION', + extras_upscaler_1: 'OPTION', + extras_upscaler_2: 'OPTION', }; var re_num = /^[.\d]+$/; -- cgit v1.2.1 From 9e4019c5ffb3c105156c6c8a9af83fde52d7f0c4 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Tue, 22 Aug 2023 12:00:29 +0300 Subject: make it possible to localize tooltips and placeholders --- javascript/localization.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'javascript/localization.js') diff --git a/javascript/localization.js b/javascript/localization.js index 0c9032f9..26f21bcf 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -107,12 +107,46 @@ function processNode(node) { }); } +function localizeWholePage(){ + processNode(gradioApp()); + + function elem(comp) { + if(comp.props.elem_id) { + elem_id = comp.props.elem_id; + } else{ + elem_id = "component-" + comp.id; + } + + return gradioApp().getElementById(elem_id); + } + + for(comp of window.gradio_config.components) { + if(comp.props.webui_tooltip) { + var e = elem(comp); + + var tl = e ? getTranslation(e.title) : undefined; + if (tl !== undefined) { + e.title = tl; + } + } + if(comp.props.placeholder) { + var e = elem(comp); + var textbox = e ? e.querySelector('[placeholder]') : null; + + var tl = textbox ? getTranslation(textbox.placeholder) : undefined; + if (tl !== undefined) { + textbox.placeholder = tl; + } + } + } +} + function dumpTranslations() { if (!hasLocalization()) { // If we don't have any localization, // we will not have traversed the app to find // original_lines, so do that now. - processNode(gradioApp()); + localizeWholePage(); } var dumped = {}; if (localization.rtl) { @@ -154,7 +188,7 @@ document.addEventListener("DOMContentLoaded", function() { }); }); - processNode(gradioApp()); + localizeWholePage(); if (localization.rtl) { // if the language is from right to left, (new MutationObserver((mutations, observer) => { // wait for the style to load -- cgit v1.2.1 From 0d90064e9e00612b1e065eba4e7b394e7892af34 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Tue, 22 Aug 2023 13:57:05 +0300 Subject: eslint --- javascript/localization.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'javascript/localization.js') diff --git a/javascript/localization.js b/javascript/localization.js index 26f21bcf..8f00c186 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -107,33 +107,28 @@ function processNode(node) { }); } -function localizeWholePage(){ +function localizeWholePage() { processNode(gradioApp()); function elem(comp) { - if(comp.props.elem_id) { - elem_id = comp.props.elem_id; - } else{ - elem_id = "component-" + comp.id; - } - + var elem_id = comp.props.elem_id ? comp.props.elem_id : "component-" + comp.id; return gradioApp().getElementById(elem_id); } - for(comp of window.gradio_config.components) { - if(comp.props.webui_tooltip) { - var e = elem(comp); + for (var comp of window.gradio_config.components) { + if (comp.props.webui_tooltip) { + let e = elem(comp); - var tl = e ? getTranslation(e.title) : undefined; + let tl = e ? getTranslation(e.title) : undefined; if (tl !== undefined) { e.title = tl; } } - if(comp.props.placeholder) { - var e = elem(comp); - var textbox = e ? e.querySelector('[placeholder]') : null; + if (comp.props.placeholder) { + let e = elem(comp); + let textbox = e ? e.querySelector('[placeholder]') : null; - var tl = textbox ? getTranslation(textbox.placeholder) : undefined; + let tl = textbox ? getTranslation(textbox.placeholder) : undefined; if (tl !== undefined) { textbox.placeholder = tl; } -- cgit v1.2.1