[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.
This commit is contained in:
Martin Trigaux
2016-06-27 12:05:36 +02:00
parent 0fa052cc1e
commit 5abcbf0eb2
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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);
}
}
@@ -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];