From 57a3d146e3e193904c1c5e148f7244b9d045f157 Mon Sep 17 00:00:00 2001 From: Sakura-Luna <53183413+Sakura-Luna@users.noreply.github.com> Date: Fri, 14 Apr 2023 01:23:54 +0800 Subject: [PATCH] Tooltip localization support --- javascript/hints.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/javascript/hints.js b/javascript/hints.js index f48a0eb6..a836d755 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -117,16 +117,16 @@ titles = { onUiUpdate(function(){ gradioApp().querySelectorAll('span, button, select, p').forEach(function(span){ - tooltip = titles[span.textContent]; + tooltip = localization[titles[span.textContent]] || titles[span.textContent]; if(!tooltip){ - tooltip = titles[span.value]; + tooltip = localization[titles[span.value]] || titles[span.value]; } if(!tooltip){ for (const c of span.classList) { if (c in titles) { - tooltip = titles[c]; + tooltip = localization[titles[c]] || titles[c]; break; } } @@ -141,7 +141,7 @@ onUiUpdate(function(){ if (select.onchange != null) return; select.onchange = function(){ - select.title = titles[select.value] || ""; + select.title = localization[titles[select.value]] || titles[select.value] || ""; } }) })