aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javascript/localization.js38
1 files changed, 36 insertions, 2 deletions
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