From 385129bd51d7c88f71615ec0dc37039dbb1d2adf Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 28 Jul 2024 01:06:25 +0200 Subject: [PATCH] luci-app-commands: use client side translation in JavaScript blocks Do not interpolate translated strings on the server side, use browser side translation calls instead to avoid potential quote escaping issues. Fixes: #7213 Fixes: 119fd22ebf ("luci-app-commands: replace i18n single quotes with double-quotes") Signed-off-by: Jo-Philipp Wich --- .../ucode/template/commands.ut | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/applications/luci-app-commands/ucode/template/commands.ut b/applications/luci-app-commands/ucode/template/commands.ut index 8e5ce0b486..48850598d7 100644 --- a/applications/luci-app-commands/ucode/template/commands.ut +++ b/applications/luci-app-commands/ucode/template/commands.ut @@ -45,7 +45,7 @@ { output.innerHTML = '{{ _('Loading') }} ' + - '{{ _('Waiting for command to complete...') }}' + _('Waiting for command to complete...') ; legend.parentNode.style.display = 'block'; @@ -57,20 +57,20 @@ if (st) { if (st.binary) - st.stdout = '[{{ _('Binary data not displayed, download instead.') }}]'; + st.stdout = '[' + _('Binary data not displayed, download instead.') + ']'; legend.style.display = 'none'; output.innerHTML = String.format( '
# %h\n%h%h
' + - '
%s ({{ _('Code:') }} %d)
', + '
%h (%h %d)
', st.command, st.stdout, st.stderr, - (st.exitcode == 0) ? '{{ _('Command successful') }}' : '{{ _('Command failed') }}', - st.exitcode); + (st.exitcode == 0) ? _('Command successful') : _('Command failed'), + _('Code:'), st.exitcode); } else { legend.style.display = 'none'; - output.innerHTML = '{{ _('Failed to execute command!') }}'; + output.innerHTML = '%h'.format(_('Failed to execute command!')); } location.hash = '#output'; @@ -114,8 +114,9 @@ legend.style.display = 'none'; output.parentNode.style.display = 'block'; output.innerHTML = String.format( - '

{{ _('Download execution result') }} %s

{{ _('Or display result') }} %s

', - link, link, link_nodownload, link_nodownload + '

%h %s

%h %s

', + _('Download execution result'), link, link, + _('Or display result'), link_nodownload, link_nodownload ); location.hash = '#output'; -- 2.30.2