diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-07-28 01:06:25 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-07-28 01:08:01 +0200 |
commit | 385129bd51d7c88f71615ec0dc37039dbb1d2adf (patch) | |
tree | 7935c2b8a59555a1786e33d1d4dc73d4e833ea56 | |
parent | 1021ecef108532b0d9af3409cf754b842e344b20 (diff) |
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 <jo@mein.io>
-rw-r--r-- | applications/luci-app-commands/ucode/template/commands.ut | 17 |
1 files 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 = '<img src="{{ resource }}/icons/loading.gif" alt="{{ _('Loading') }}" style="vertical-align:middle" /> ' + - '{{ _('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( '<pre><strong># %h\n</strong>%h<span style="color:red">%h</span></pre>' + - '<div class="alert-message warning">%s ({{ _('Code:') }} %d)</div>', + '<div class="alert-message warning">%h (%h %d)</div>', 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 = '<span class="error">{{ _('Failed to execute command!') }}</span>'; + output.innerHTML = '<span class="error">%h</span>'.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( - '<div class="alert-message"><p>{{ _('Download execution result') }} <a href="%s">%s</a></p><p>{{ _('Or display result') }} <a href="%s">%s</a></p></div>', - link, link, link_nodownload, link_nodownload + '<div class="alert-message"><p>%h <a href="%s">%s</a></p><p>%h <a href="%s">%s</a></p></div>', + _('Download execution result'), link, link, + _('Or display result'), link_nodownload, link_nodownload ); location.hash = '#output'; |