summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authortsabi <>2012-11-29 01:22:00 +0100
committertsabi <>2012-11-29 01:22:00 +0100
commit92e87f7e6fa762af05b03a6a82d1e135f78172cb (patch)
tree00bae01aaccf1e159ba254064542bd58efad85c8 /addons/web/static/src
parent93091dad79c4df972c8686b2fda82547604e8cd5 (diff)
Mark strings to be translated.
Maybe some missed, but most of them marked. bzr revid: tsabi-20121129002200-20tppzvh0ap5tfwe
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/chrome.js34
-rw-r--r--addons/web/static/src/js/dates.js13
-rw-r--r--addons/web/static/src/js/formats.js14
-rw-r--r--addons/web/static/src/js/view_form.js24
-rw-r--r--addons/web/static/src/js/view_list.js14
-rw-r--r--addons/web/static/src/js/view_list_editable.js6
-rw-r--r--addons/web/static/src/js/views.js12
7 files changed, 60 insertions, 57 deletions
diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js
index 940bf800851..91cca8468d1 100644
--- a/addons/web/static/src/js/chrome.js
+++ b/addons/web/static/src/js/chrome.js
@@ -289,7 +289,7 @@ instance.web.CrashManager = instance.web.Class.extend({
});
instance.web.Loading = instance.web.Widget.extend({
- template: 'Loading',
+ template: _t("Loading"),
init: function(parent) {
this._super(parent);
this.count = 0;
@@ -390,11 +390,11 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
self.$el.find("form[name=restore_db_form]").validate({ submitHandler: self.do_restore });
self.$el.find("form[name=change_pwd_form]").validate({
messages: {
- old_pwd: "Please enter your previous password",
- new_pwd: "Please enter your new password",
+ old_pwd: _t("Please enter your previous password"),
+ new_pwd: _t("Please enter your new password"),
confirm_pwd: {
- required: "Please confirm your new password",
- equalTo: "The confirmation does not match the password"
+ required: _t("Please confirm your new password"),
+ equalTo: _t("The confirmation does not match the password")
}
},
submitHandler: self.do_change_password
@@ -478,7 +478,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
self.display_error(result);
return;
}
- self.do_notify("Duplicating database", "The database has been duplicated.");
+ self.do_notify(_t("Duplicating database"), _t("The database has been duplicated."));
self.start();
});
},
@@ -488,7 +488,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
fields = $form.serializeArray(),
$db_list = $form.find('[name=drop_db]'),
db = $db_list.val();
- if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
+ if (!db || !confirm(_.str.sprintf(_t("Do you really want to delete the database: %s ?"), db))) {
return;
}
self.rpc("/web/database/drop", {'fields': fields}).done(function(result) {
@@ -496,7 +496,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
self.display_error(result);
return;
}
- self.do_notify("Dropping database", "The database '" + db + "' has been dropped");
+ self.do_notify(_t("Dropping database"), _.str.sprintf(_t("The database %s has been dropped"), db));
self.start();
});
},
@@ -511,7 +511,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
error: function(error){
if(error){
self.display_error({
- title: 'Backup Database',
+ title: _t("Backup Database"),
error: 'AccessDenied'
});
}
@@ -534,13 +534,13 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
if (body.indexOf('403 Forbidden') !== -1) {
self.display_error({
- title: 'Access Denied',
- error: 'Incorrect super-administrator password'
+ title: _t("Access Denied"),
+ error: _t("Incorrect super-administrator password")
});
} else {
self.display_error({
- title: 'Restore Database',
- error: 'Could not restore the database'
+ title: _t("Restore Database"),
+ error: _t("Could not restore the database")
});
}
},
@@ -560,7 +560,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({
return;
}
self.unblockUI();
- self.do_notify("Changed Password", "Password has been changed successfully");
+ self.do_notify(_t("Changed Password"), _t("Password has been changed successfully"));
});
},
do_exit: function () {
@@ -642,7 +642,7 @@ instance.web.Login = instance.web.Widget.extend({
}
var db = this.$("form [name=db]").val();
if (!db) {
- this.do_warn("Login", "No database selected !");
+ this.do_warn(_t("Login"), _t("No database selected !"));
return false;
}
var login = this.$("form input[name=login]").val();
@@ -678,7 +678,7 @@ instance.web.Login = instance.web.Widget.extend({
self.trigger('login_successful');
}, function () {
self.$(".oe_login_pane").fadeIn("fast", function() {
- self.show_error("Invalid username or password");
+ self.show_error(_t("Invalid username or password"));
});
});
},
@@ -765,7 +765,7 @@ instance.web.ChangePassword = instance.web.Widget.extend({
template: "ChangePassword",
start: function() {
var self = this;
- this.getParent().dialog_title = "Change Password";
+ this.getParent().dialog_title = _t("Change Password");
var $button = self.$el.find('.oe_form_button');
$button.appendTo(this.getParent().$buttons);
$button.eq(2).click(function(){
diff --git a/addons/web/static/src/js/dates.js b/addons/web/static/src/js/dates.js
index 3db48c8412a..1a48463df2c 100644
--- a/addons/web/static/src/js/dates.js
+++ b/addons/web/static/src/js/dates.js
@@ -1,5 +1,6 @@
openerp.web.dates = function(instance) {
+var _t = instance.web._t;
/**
* Converts a string to a Date javascript object using OpenERP's
@@ -18,11 +19,11 @@ instance.web.str_to_datetime = function(str) {
var regex = /^(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)(?:\.\d+)?$/;
var res = regex.exec(str);
if ( !res ) {
- throw new Error("'" + str + "' is not a valid datetime");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid datetime"), str));
}
var obj = Date.parseExact(res[1] + " UTC", 'yyyy-MM-dd HH:mm:ss zzz');
if (! obj) {
- throw new Error("'" + str + "' is not a valid datetime");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid datetime"), str));
}
return obj;
};
@@ -45,11 +46,11 @@ instance.web.str_to_date = function(str) {
var regex = /^\d\d\d\d-\d\d-\d\d$/;
var res = regex.exec(str);
if ( !res ) {
- throw new Error("'" + str + "' is not a valid date");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid date"), str));
}
var obj = Date.parseExact(str, 'yyyy-MM-dd');
if (! obj) {
- throw new Error("'" + str + "' is not a valid date");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid date"), str));
}
return obj;
};
@@ -72,11 +73,11 @@ instance.web.str_to_time = function(str) {
var regex = /^(\d\d:\d\d:\d\d)(?:\.\d+)?$/;
var res = regex.exec(str);
if ( !res ) {
- throw new Error("'" + str + "' is not a valid time");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid time"), str));
}
var obj = Date.parseExact("1970-01-01 " + res[1], 'yyyy-MM-dd HH:mm:ss');
if (! obj) {
- throw new Error("'" + str + "' is not a valid time");
+ throw new Error(_.str.sprintf(_t("'%s' is not a valid time"), str));
}
return obj;
};
diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js
index e586b94db6b..9432b02826f 100644
--- a/addons/web/static/src/js/formats.js
+++ b/addons/web/static/src/js/formats.js
@@ -224,7 +224,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
} while(tmp !== value);
tmp = Number(value);
if (isNaN(tmp))
- throw new Error(value + " is not a correct integer");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct integer"), value));
return tmp;
case 'float':
var tmp = Number(value);
@@ -239,7 +239,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
var reformatted_value = tmp.replace(instance.web._t.database.parameters.decimal_point, ".");
var parsed = Number(reformatted_value);
if (isNaN(parsed))
- throw new Error(value + " is not a correct float");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct float"), value));
return parsed;
case 'float_time':
var factor = 1;
@@ -263,7 +263,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
datetime = Date.parse(value);
if (datetime !== null)
return instance.web.datetime_to_str(datetime);
- throw new Error(value + " is not a valid datetime");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct datetime"), value));
case 'date':
var date = Date.parseExact(value, date_pattern);
if (date !== null)
@@ -271,7 +271,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
date = Date.parse(value);
if (date !== null)
return instance.web.date_to_str(date);
- throw new Error(value + " is not a valid date");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct date"), value));
case 'time':
var time = Date.parseExact(value, time_pattern);
if (time !== null)
@@ -279,7 +279,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
time = Date.parse(value);
if (time !== null)
return instance.web.time_to_str(time);
- throw new Error(value + " is not a valid time");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct time"), value));
}
return value;
};
@@ -294,7 +294,7 @@ instance.web.auto_str_to_date = function(value, type) {
try {
return instance.web.str_to_time(value);
} catch(e) {}
- throw new Error("'" + value + "' is not a valid date, datetime nor time");
+ throw new Error(_.str.sprintf(_t("'%s' is not a correct date, datetime nor time"), value));
};
instance.web.auto_date_to_str = function(value, type) {
@@ -306,7 +306,7 @@ instance.web.auto_date_to_str = function(value, type) {
case 'time':
return instance.web.time_to_str(value);
default:
- throw new Error(type + " is not convertible to date, datetime nor time");
+ throw new Error(_.str.sprintf(_t("'%s' is not convertible to date, datetime nor time"), type));
}
};
diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js
index 927d585a5be..dd9b2be5fb0 100644
--- a/addons/web/static/src/js/view_form.js
+++ b/addons/web/static/src/js/view_form.js
@@ -148,7 +148,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
load_form: function(data) {
var self = this;
if (!data) {
- throw new Error("No data provided.");
+ throw new Error(_t("No data provided."));
}
if (this.arch) {
throw "Form view does not support multiple calls to load_form";
@@ -316,12 +316,12 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var self = this, set_values = [];
if (!record) {
this.set({ 'title' : undefined });
- this.do_warn("Form", "The record could not be found in the database.", true);
+ this.do_warn(_t("Form"), _t("The record could not be found in the database."), true);
return $.Deferred().reject();
}
this.datarecord = record;
this._actualize_mode();
- this.set({ 'title' : record.id ? record.display_name : "New" });
+ this.set({ 'title' : record.id ? record.display_name : _t("New") });
_(this.fields).each(function (field, f) {
field._dirty_flag = false;
@@ -431,7 +431,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
var onchange = _.str.trim(on_change);
var call = onchange.match(/^\s?(.*?)\((.*?)\)\s?$/);
if (!call) {
- throw new Error("Wrong on change format: " + onchange);
+ throw new Error(_.str.sprintf( _t("Wrong on change format: %s"), onchange ));
}
var method = call[1];
@@ -872,7 +872,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}).value();
warnings.unshift('<ul>');
warnings.push('</ul>');
- this.do_warn("The following fields are invalid :", warnings.join(''));
+ this.do_warn(_t("The following fields are invalid:", warnings.join(''));
},
/**
* Reload the form after saving
@@ -1241,11 +1241,11 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
_.each(this.fields_to_init, function($elem) {
var name = $elem.attr("name");
if (!self.fvg.fields[name]) {
- throw new Error("Field '" + name + "' specified in view could not be found.");
+ throw new Error(_.str.sprintf(_t("Field '%s' specified in view could not be found."), name));
}
var obj = self.fields_registry.get_any([$elem.attr('widget'), self.fvg.fields[name].type]);
if (!obj) {
- throw new Error("Widget type '"+ $elem.attr('widget') + "' is not implemented");
+ throw new Error(_.str.sprintf(_t("Widget type '%s' is not implemented"), $elem.attr('widget')));
}
var w = new (obj)(self.view, instance.web.xml_to_json($elem[0]));
var $label = self.labels[$elem.attr("name")];
@@ -2319,7 +2319,7 @@ instance.web.form.FieldEmail = instance.web.form.FieldChar.extend({
},
on_button_clicked: function() {
if (!this.get('value') || !this.is_syntax_valid()) {
- this.do_warn("E-mail error", "Can't send email to invalid e-mail address");
+ this.do_warn(_t("E-mail error"), _t("Can't send email to invalid e-mail address"));
} else {
location.href = 'mailto:' + this.get('value');
}
@@ -2348,7 +2348,7 @@ instance.web.form.FieldUrl = instance.web.form.FieldChar.extend({
},
on_button_clicked: function() {
if (!this.get('value')) {
- this.do_warn("Resource error", "This resource is empty");
+ this.do_warn(_t("Resource error"), _t("This resource is empty"));
} else {
var url = $.trim(this.get('value'));
if(/^www\./i.test(url))
@@ -3385,7 +3385,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
var views = [];
_.each(modes, function(mode) {
if (! _.include(["list", "tree", "graph", "kanban"], mode)) {
- throw new Error(_.str.sprintf("View type '%s' is not supported in One2Many.", mode));
+ throw new Error(_.str.sprintf(_t("View type '%s' is not supported in One2Many."), mode));
}
var view = {
view_id: false,
@@ -4840,7 +4840,7 @@ instance.web.form.FieldBinary = instance.web.form.AbstractField.extend(instance.
},
on_file_uploaded: function(size, name, content_type, file_base64) {
if (size === false) {
- this.do_warn("File Upload", "There was a problem while uploading your file");
+ this.do_warn(_t("File Upload"), _t("There was a problem while uploading your file"));
// TODO: use openerp web crashmanager
console.warn("Error while uploading file : ", name);
} else {
@@ -5009,7 +5009,7 @@ instance.web.form.FieldMany2ManyBinaryMultiFiles = instance.web.form.AbstractFie
this.field_manager = field_manager;
this.node = node;
if(this.field.type != "many2many" || this.field.relation != 'ir.attachment') {
- throw "The type of the field '"+this.field.string+"' must be a many2many field with a relation to 'ir.attachment' model.";
+ throw _.str.sprintf(_t("The type of the field '%s' must be a many2many field with a relation to 'ir.attachment' model."), this.field.string);
}
this.ds_file = new instance.web.DataSetSearch(this, 'ir.attachment');
this.fileupload_id = _.uniqueId('oe_fileupload_temp');
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js
index 13c41d48599..5008d1765a6 100644
--- a/addons/web/static/src/js/view_list.js
+++ b/addons/web/static/src/js/view_list.js
@@ -389,7 +389,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
if (range_stop > total) {
range_stop = total;
}
- spager = _.str.sprintf('%d-%d of %d', range_start, range_stop, total);
+ spager = _.str.sprintf(_t("%d-%d of %d"), range_start, range_stop, total);
}
this.$pager.find('.oe_list_pager_state').text(spager);
@@ -887,8 +887,8 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
var $row;
if (attribute === 'id') {
if (old_value) {
- throw new Error("Setting 'id' attribute on existing record "
- + JSON.stringify(record.attributes));
+ throw new Error(_.str.sprintf( _t("Setting 'id' attribute on existing record %s"),
+ JSON.stringify(record.attributes) ));
}
if (!_.contains(self.dataset.ids, value)) {
// add record to dataset if not already in (added by
@@ -956,7 +956,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
if (row_id) {
e.stopPropagation();
if (!self.dataset.select_id(row_id)) {
- throw new Error("Could not find id in dataset");
+ throw new Error(_t("Could not find id in dataset"));
}
self.row_clicked(e);
}
@@ -1016,7 +1016,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
var command = value[0];
// 1. an array of m2m commands (usually (6, false, ids))
if (command[0] !== 6) {
- throw new Error(_t("Unknown m2m command ") + command[0]);
+ throw new Error(_.str.sprintf( _t("Unknown m2m command %s"), command[0]));
}
ids = command[2];
} else {
@@ -1324,7 +1324,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
}
// group_label is html-clean (through format or explicit
// escaping if format failed), can inject straight into HTML
- $group_column.html(_.str.sprintf("%s (%d)",
+ $group_column.html(_.str.sprintf(_t("%s (%d)"),
group_label, group.length));
if (group.length && group.openable) {
@@ -1743,7 +1743,7 @@ var Record = instance.web.Class.extend(/** @lends Record# */{
} else if (val instanceof Array) {
output[k] = val[0];
} else {
- throw new Error("Can't convert value " + val + " to context");
+ throw new Error(_.str.sprintf(_t("Can't convert value %s to context"), val));
}
}
return output;
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js
index 7fe6a8ec42b..e3f35e2068c 100644
--- a/addons/web/static/src/js/view_list_editable.js
+++ b/addons/web/static/src/js/view_list_editable.js
@@ -3,7 +3,9 @@
* @namespace
*/
openerp.web.list_editable = function (instance) {
- // editability status of list rows
+ var _t = instance.web._t;
+
+ // editability status of list rows
instance.web.ListView.prototype.defaults.editable = null;
// TODO: not sure second @lends on existing item is correct, to check
@@ -775,7 +777,7 @@ openerp.web.list_editable = function (instance) {
cancel: function (force) {
if (!(force || this.form.can_be_discarded())) {
return $.Deferred().reject({
- message: "The form's data can not be discarded"}).promise();
+ message: _t("The form's data can not be discarded")}).promise();
}
var record = this.record;
this.record = null;
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index ddedcdd2ff6..600a0b065c1 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -786,7 +786,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
break;
case 'tests':
this.do_action({
- name: "JS Tests",
+ name: _t("JS Tests"),
target: 'new',
type : 'ir.actions.act_url',
url: '/web/tests?mod=*'
@@ -814,7 +814,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
break;
case 'translate':
this.do_action({
- name: "Technical Translation",
+ name: _t("Technical Translation"),
res_model : 'ir.translation',
domain : [['type', '!=', 'object'], '|', ['name', '=', this.dataset.model], ['name', 'ilike', this.dataset.model + ',']],
views: [[false, 'list'], [false, 'form']],
@@ -1395,7 +1395,7 @@ instance.web.json_node_to_xml = function(node, human_readable, indent) {
return sindent + node;
} else if (typeof(node.tag) !== 'string' || !node.children instanceof Array || !node.attrs instanceof Object) {
throw new Error(
- _.str.sprintf("Node [%s] is not a JSONified XML node",
+ _.str.sprintf(_t("Node [%s] is not a JSONified XML node"),
JSON.stringify(node)));
}
for (var attr in node.attrs) {
@@ -1429,7 +1429,7 @@ instance.web.xml_to_str = function(node) {
} else if (window.ActiveXObject) {
return node.xml;
} else {
- throw new Error("Could not serialize XML");
+ throw new Error(_t("Could not serialize XML"));
}
};
instance.web.str_to_xml = function(s) {
@@ -1437,7 +1437,7 @@ instance.web.str_to_xml = function(s) {
var dp = new DOMParser();
var r = dp.parseFromString(s, "text/xml");
if (r.body && r.body.firstChild && r.body.firstChild.nodeName == 'parsererror') {
- throw new Error("Could not parse string to xml");
+ throw new Error(_t("Could not parse string to xml"));
}
return r;
}
@@ -1445,7 +1445,7 @@ instance.web.str_to_xml = function(s) {
try {
xDoc = new ActiveXObject("MSXML2.DOMDocument");
} catch (e) {
- throw new Error("Could not find a DOM Parser: " + e.message);
+ throw new Error(_.str.sprintf( _t("Could not find a DOM Parser: %s"), e.message));
}
xDoc.async = false;
xDoc.preserveWhiteSpace = true;