From e05ee9389735683bf277d962d2bb9ba1908bdf13 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 7 Dec 2023 04:09:39 +0100 Subject: luci-mod-network: Rework address helptext for DHCP Ease translators lives. This introduces the function customi18n for positional string variables. Word and grammatical ordering of some languages breaks guarantees for positional string arguments. Signed-off-by: Paul Donald --- .../luci-static/resources/view/network/dhcp.js | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'modules/luci-mod-network/htdocs') diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 45a2e2573f..91b6e6a189 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -308,12 +308,32 @@ return view.extend({ o.placeholder = '/example.org/10.1.2.3'; o.validate = validateServerSpec; + function customi18n(template, values) { + return template.replace(/\{(\w+)\}/g, (match, key) => values[key] || match); + }; + o = s.taboption('general', form.DynamicList, 'address', _('Addresses'), _('Resolve specified FQDNs to an IP.') + '
' + - _('Syntax: /fqdn[/fqdn…]/[ipaddr].') + '
' + - _('/#/ matches any domain. /example.com/ returns NXDOMAIN.') + '
' + - _('/example.com/# returns NULL addresses (0.0.0.0 and ::) for example.com and its subdomains.')); + customi18n(_('Syntax: {code_syntax}.'), + {code_syntax: '/fqdn[/fqdn…]/[ipaddr]'}) + '
' + + customi18n(_('{example_nx} returns {nxdomain}.', + 'hint: /example.com/ returns NXDOMAIN.'), + {example_nx: '/example.com/', nxdomain: 'NXDOMAIN'}) + '
' + + customi18n(_('{any_domain} matches any domain (and returns {nxdomain}).', + 'hint: /#/ matches any domain (and returns NXDOMAIN).'), + {any_domain:'/#/', nxdomain: 'NXDOMAIN'}) + '
' + + customi18n( + _('{example_null} returns {null_addr} addresses ({null_ipv4}, {null_ipv6}) for {example_com} and its subdomains.', + 'hint: /example.com/# returns NULL addresses (0.0.0.0, ::) for example.com and its subdomains.'), + { example_null: '/example.com/#', + null_addr: 'NULL', + null_ipv4: '0.0.0.0', + null_ipv6: '::', + example_com: 'example.com', + } + ) + ); o.optional = true; o.placeholder = '/router.local/router.lan/192.168.0.1'; -- cgit v1.2.3