|
@@ -1,10 +1,9 @@
|
|
|
|
|
|
// localization = {} -- the dict with translations is created by the backend
|
|
// localization = {} -- the dict with translations is created by the backend
|
|
|
|
|
|
-ignore_ids_for_localization = {
|
|
|
|
|
|
+var ignore_ids_for_localization = {
|
|
setting_sd_hypernetwork: 'OPTION',
|
|
setting_sd_hypernetwork: 'OPTION',
|
|
setting_sd_model_checkpoint: 'OPTION',
|
|
setting_sd_model_checkpoint: 'OPTION',
|
|
- setting_realesrgan_enabled_models: 'OPTION',
|
|
|
|
modelmerger_primary_model_name: 'OPTION',
|
|
modelmerger_primary_model_name: 'OPTION',
|
|
modelmerger_secondary_model_name: 'OPTION',
|
|
modelmerger_secondary_model_name: 'OPTION',
|
|
modelmerger_tertiary_model_name: 'OPTION',
|
|
modelmerger_tertiary_model_name: 'OPTION',
|
|
@@ -19,11 +18,11 @@ ignore_ids_for_localization = {
|
|
extras_upscaler_2: 'SPAN',
|
|
extras_upscaler_2: 'SPAN',
|
|
};
|
|
};
|
|
|
|
|
|
-re_num = /^[\.\d]+$/;
|
|
|
|
-re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u;
|
|
|
|
|
|
+var re_num = /^[.\d]+$/;
|
|
|
|
+var re_emoji = /[\p{Extended_Pictographic}\u{1F3FB}-\u{1F3FF}\u{1F9B0}-\u{1F9B3}]/u;
|
|
|
|
|
|
-original_lines = {};
|
|
|
|
-translated_lines = {};
|
|
|
|
|
|
+var original_lines = {};
|
|
|
|
+var translated_lines = {};
|
|
|
|
|
|
function hasLocalization() {
|
|
function hasLocalization() {
|
|
return window.localization && Object.keys(window.localization).length > 0;
|
|
return window.localization && Object.keys(window.localization).length > 0;
|
|
@@ -31,7 +30,7 @@ function hasLocalization() {
|
|
|
|
|
|
function textNodesUnder(el) {
|
|
function textNodesUnder(el) {
|
|
var n, a = [], walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
|
|
var n, a = [], walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
|
|
- while (n = walk.nextNode()) a.push(n);
|
|
|
|
|
|
+ while ((n = walk.nextNode())) a.push(n);
|
|
return a;
|
|
return a;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -64,7 +63,7 @@ function getTranslation(text) {
|
|
original_lines[text] = 1;
|
|
original_lines[text] = 1;
|
|
}
|
|
}
|
|
|
|
|
|
- tl = localization[text];
|
|
|
|
|
|
+ var tl = localization[text];
|
|
if (tl !== undefined) {
|
|
if (tl !== undefined) {
|
|
translated_lines[tl] = 1;
|
|
translated_lines[tl] = 1;
|
|
}
|
|
}
|
|
@@ -77,7 +76,7 @@ function processTextNode(node) {
|
|
|
|
|
|
if (!canBeTranslated(node, text)) return;
|
|
if (!canBeTranslated(node, text)) return;
|
|
|
|
|
|
- tl = getTranslation(text);
|
|
|
|
|
|
+ var tl = getTranslation(text);
|
|
if (tl !== undefined) {
|
|
if (tl !== undefined) {
|
|
node.textContent = tl;
|
|
node.textContent = tl;
|
|
}
|
|
}
|
|
@@ -90,14 +89,14 @@ function processNode(node) {
|
|
}
|
|
}
|
|
|
|
|
|
if (node.title) {
|
|
if (node.title) {
|
|
- tl = getTranslation(node.title);
|
|
|
|
|
|
+ let tl = getTranslation(node.title);
|
|
if (tl !== undefined) {
|
|
if (tl !== undefined) {
|
|
node.title = tl;
|
|
node.title = tl;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (node.placeholder) {
|
|
if (node.placeholder) {
|
|
- tl = getTranslation(node.placeholder);
|
|
|
|
|
|
+ let tl = getTranslation(node.placeholder);
|
|
if (tl !== undefined) {
|
|
if (tl !== undefined) {
|
|
node.placeholder = tl;
|
|
node.placeholder = tl;
|
|
}
|
|
}
|
|
@@ -157,21 +156,21 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
|
|
processNode(gradioApp());
|
|
processNode(gradioApp());
|
|
|
|
|
|
- if (localization.rtl) { // if the language is from right to left,
|
|
|
|
|
|
+ if (localization.rtl) { // if the language is from right to left,
|
|
(new MutationObserver((mutations, observer) => { // wait for the style to load
|
|
(new MutationObserver((mutations, observer) => { // wait for the style to load
|
|
mutations.forEach(mutation => {
|
|
mutations.forEach(mutation => {
|
|
mutation.addedNodes.forEach(node => {
|
|
mutation.addedNodes.forEach(node => {
|
|
if (node.tagName === 'STYLE') {
|
|
if (node.tagName === 'STYLE') {
|
|
observer.disconnect();
|
|
observer.disconnect();
|
|
|
|
|
|
- for (const x of node.sheet.rules) { // find all rtl media rules
|
|
|
|
|
|
+ for (const x of node.sheet.rules) { // find all rtl media rules
|
|
if (Array.from(x.media || []).includes('rtl')) {
|
|
if (Array.from(x.media || []).includes('rtl')) {
|
|
- x.media.appendMedium('all'); // enable them
|
|
|
|
|
|
+ x.media.appendMedium('all'); // enable them
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- })).observe(gradioApp(), { childList: true });
|
|
|
|
|
|
+ })).observe(gradioApp(), {childList: true});
|
|
}
|
|
}
|
|
});
|
|
});
|