diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-06-13 15:16:12 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 15:36:26 +0200 |
commit | 1bd9ee91af48d4691335dda0478b4b900d966968 (patch) | |
tree | 421083ee0f22309730103dc8ba37ca512acc84e8 /modules | |
parent | 0560858380a583e0ce26a99a2396d8255f138cf8 (diff) |
luci-base: validation.js: rework translation labels
Rework validation error translations for compount operators such
as list() or neg() to not rely that much on specific native language
grammar.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/validation.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/validation.js b/modules/luci-base/htdocs/luci-static/resources/validation.js index f0c89d804..621e5b8bd 100644 --- a/modules/luci-base/htdocs/luci-static/resources/validation.js +++ b/modules/luci-base/htdocs/luci-static/resources/validation.js @@ -56,7 +56,7 @@ var Validator = L.Class.extend({ valid = this.vstack[0].apply(this, this.vstack[1]); if (valid !== true) { - this.field.setAttribute('data-tooltip', _('Expecting %s').format(this.error)); + this.field.setAttribute('data-tooltip', _('Expecting: %s').format(this.error)); this.field.setAttribute('data-tooltip-style', 'error'); this.field.dispatchEvent(new CustomEvent('validation-failure', { bubbles: true })); return false; @@ -453,7 +453,9 @@ var ValidatorFactory = L.Class.extend({ } } - return this.assert(false, _('one of:\n - %s'.format(errors.join('\n - ')))); + var t = _('One of the following: %s'); + + return this.assert(false, t.format('\n - ' + errors.join('\n - '))); }, and: function() { @@ -472,7 +474,12 @@ var ValidatorFactory = L.Class.extend({ }, neg: function() { - return this.apply('or', this.value.replace(/^[ \t]*![ \t]*/, ''), arguments); + this.value = this.value.replace(/^[ \t]*![ \t]*/, ''); + + if (arguments[0].apply(this, arguments[1])) + return this.assert(true); + + return this.assert(false, _('Potential negation of: %s').format(this.error)); }, list: function(subvalidator, subargs) { |