diff options
| author | Martin Trigaux <mat@odoo.com> | 2016-06-27 12:03:45 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2016-06-27 12:05:36 +0200 |
| commit | 5abcbf0eb2a8618106752e46f9e0db2d42580f49 (patch) | |
| tree | f804e4539d8ab70ad95d2898b99461607be04dbc | |
| parent | 0fa052cc1ee1803b355388fd3e531ea70dbc9e59 (diff) | |
[FIX] js: translations and string substitutions
_('foo '+bar) does not work as `bar` is a variable with undefinied content
during translation export (and variable content during evaluation) so a match
will not be found.
Also trailing spaces are stripped during synchronisation with transifex.
The proper syntax would be
_.str.sprintf(_t("foo %s"), bar)
but to avoid breaking existing translations (need to reexport .pot)
use the syntax
_("foo ") + " " + bar
that is more stable friendly.
The 'No value found for the field...' string is not possible to be fixed without
breaking the translations should be split at least twice.
Write it the propre way directly.
| -rw-r--r-- | addons/web/i18n/web.pot | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/framework/pyeval.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_relational_widgets.js | 3 |
3 files changed, 4 insertions, 3 deletions
diff --git a/addons/web/i18n/web.pot b/addons/web/i18n/web.pot index 06166ac4b37..be3979a31b9 100644 --- a/addons/web/i18n/web.pot +++ b/addons/web/i18n/web.pot @@ -1503,7 +1503,7 @@ msgstr "" #. openerp-web #: code:addons/web/static/src/js/views/form_relational_widgets.js:328 #, python-format -msgid "No value found for the field for value " +msgid "No value found for the field %s for value %s" msgstr "" #. module: web diff --git a/addons/web/static/src/js/framework/pyeval.js b/addons/web/static/src/js/framework/pyeval.js index 2b553d37e0f..d0708bdf356 100644 --- a/addons/web/static/src/js/framework/pyeval.js +++ b/addons/web/static/src/js/framework/pyeval.js @@ -958,7 +958,7 @@ function eval_arg (arg) { case 'context': case 'compound_context': return pyeval('contexts', [arg]); default: - throw new Error(_t("Unknown nonliteral type " + arg.__ref)); + throw new Error(_t("Unknown nonliteral type ") + ' ' + arg.__ref); } } diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index f1c6e0b36b1..beba85ac512 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -325,7 +325,8 @@ var FieldMany2One = common.AbstractField.extend(common.CompletionFieldMixin, com var dataset = new data.DataSetStatic(this, this.field.relation, self.build_context()); var def = this.alive(dataset.name_get([self.get("value")])).done(function(data) { if (!data[0]) { - self.do_warn(_t("Render"), _t("No value found for the field "+self.field.string+" for value "+self.get("value"))); + self.do_warn(_t("Render"), + _.str.sprintf(_t("No value found for the field %s for value %s"), self.field.string, self.get("value"))); return; } self.display_value["" + self.get("value")] = data[0][1]; |
