diff options
| author | Gery Debongnie <ged@openerp.com> | 2014-01-28 12:10:22 +0100 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2014-01-28 12:10:22 +0100 |
| commit | 31374c2eeffe824188b1a43768bc216a86d29b03 (patch) | |
| tree | 997bc7174872aacdb8e28fc78323ad8d03ec9097 /addons/web_graph/static/src/js | |
| parent | f38017faecc1bf6e745ca1a330c584da7ac061af (diff) | |
[IMP] this commit translates the hardcoded strings that appears in graph view (addon web_graph)
bzr revid: ged@openerp.com-20140128111022-ghoxwvlmywzr2yke
Diffstat (limited to 'addons/web_graph/static/src/js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph_widget.js | 31 | ||||
| -rw-r--r-- | addons/web_graph/static/src/js/pivot_table.js | 9 |
2 files changed, 23 insertions, 17 deletions
diff --git a/addons/web_graph/static/src/js/graph_widget.js b/addons/web_graph/static/src/js/graph_widget.js index 454af202593..c17fd0bcf43 100644 --- a/addons/web_graph/static/src/js/graph_widget.js +++ b/addons/web_graph/static/src/js/graph_widget.js @@ -4,6 +4,9 @@ (function () { 'use strict'; var QWeb = openerp.web.qweb; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + nv.dev = false; // sets nvd3 library in production mode openerp.web_graph.Graph = openerp.web.Widget.extend({ @@ -39,7 +42,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return this.model.call('fields_get', []).then(function (f) { self.fields = f; - self.fields.__count = {field:'__count', type: 'integer', string:'Quantity'}; + self.fields.__count = {field:'__count', type: 'integer', string:_t('Quantity')}; self.important_fields = self.get_search_fields(); self.measure_list = self.get_measures(); self.add_measures_to_options(); @@ -381,11 +384,11 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // Drawing the table // ---------------------------------------------------------------------- draw_table: function () { - this.pivot.main_row().title = 'Total'; + this.pivot.main_row().title = _t('Total'); if (this.pivot.measures.length == 1) { this.pivot.main_col().title = this.pivot.measures[0].string; } else { - this.pivot.main_col().title = this.title; + this.pivot.main_col().title = _t(this.title); } this.draw_top_headers(); _.each(this.pivot.rows.headers, this.proxy('draw_row')); @@ -449,7 +452,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else { make_cells(pivot.main_col().children, 1); if (pivot.get_cols_leaves().length > 1) { - header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text('Total').css('font-weight', 'bold')); + header_cells[0].push(self.make_border_cell(pivot.measures.length, height, true).text(_t('Total')).css('font-weight', 'bold')); } } @@ -554,8 +557,8 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ // No groupby if ((dim_x === 0) && (dim_y === 0)) { - data = [{key: 'Total', values:[{ - x: 'Total', + data = [{key: _t('Total'), values:[{ + x: _t('Total'), y: this.pivot.get_total(), }]}]; // Only column groupbys @@ -570,7 +573,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ } else if ((dim_x === 1) && (dim_y === 0)) { data = _.map(this.pivot.main_row().children, function (pt) { var value = self.pivot.get_total(pt), - title = (pt.title !== undefined) ? pt.title : 'Undefined'; + title = (pt.title !== undefined) ? pt.title : _t('Undefined'); return {x: title, y: value}; }); data = [{key: self.pivot.measures[0].string, values:data}]; @@ -579,24 +582,24 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ data = _.map(this.pivot.get_cols_with_depth(1), function (colhdr) { var values = _.map(self.pivot.get_rows_with_depth(1), function (header) { return { - x: header.title || 'Undefined', + x: header.title || _t('Undefined'), y: self.pivot.get_values(header.id, colhdr.id)[0] || 0 }; }); - return {key: colhdr.title || 'Undefined', values: values}; + return {key: colhdr.title || _t('Undefined'), values: values}; }); // At least two row groupby } else { var keys = _.uniq(_.map(this.pivot.get_rows_with_depth(2), function (hdr) { - return hdr.title || 'Undefined'; + return hdr.title || _t('Undefined'); })); data = _.map(keys, function (key) { var values = _.map(self.pivot.get_rows_with_depth(1), function (hdr) { var subhdr = _.find(hdr.children, function (child) { - return ((child.title === key) || ((child.title === undefined) && (key === 'Undefined'))); + return ((child.title === key) || ((child.title === undefined) && (key === _t('Undefined')))); }); return { - x: hdr.title || 'Undefined', + x: hdr.title || _t('Undefined'), y: (subhdr) ? self.pivot.get_total(subhdr)[0] : 0 }; }); @@ -640,7 +643,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ return {x: row.title, y: self.pivot.get_values(row.id,col.id)[0] || 0}; }); var title = _.map(col.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_y === 0) { title = self.pivot.measures[0].string; @@ -670,7 +673,7 @@ openerp.web_graph.Graph = openerp.web.Widget.extend({ dim_x = this.pivot.rows.groupby.length; var data = _.map(this.pivot.get_rows_leaves(), function (row) { var title = _.map(row.path, function (p) { - return p || 'Undefined'; + return p || _t('Undefined'); }).join('/'); if (dim_x === 0) { title = self.measure_label; diff --git a/addons/web_graph/static/src/js/pivot_table.js b/addons/web_graph/static/src/js/pivot_table.js index a5bfba3c09a..89ca36f3b61 100644 --- a/addons/web_graph/static/src/js/pivot_table.js +++ b/addons/web_graph/static/src/js/pivot_table.js @@ -4,6 +4,9 @@ (function () { 'use strict'; +var _lt = openerp.web._lt; +var _t = openerp.web._t; + // PivotTable requires a call to update_data after initialization openerp.web_graph.PivotTable = openerp.web.Class.extend({ @@ -13,7 +16,7 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ this.no_data = true; this.model = model; this.fields = fields; - this.fields.__count = {type: 'integer', string:'Quantity'}; + this.fields.__count = {type: 'integer', string:_t('Quantity')}; this.measures = options.measures || []; this.rows = { groupby: options.row_groupby, headers: null }; this.cols = { groupby: options.col_groupby, headers: null }; @@ -397,11 +400,11 @@ openerp.web_graph.PivotTable = openerp.web.Class.extend({ grouped_on = attrs.grouped_on ? this.raw_field(attrs.grouped_on) : false; if (value === false) { - group.attributes.value = 'undefined'; + group.attributes.value = _t('undefined'); } else if (grouped_on && this.fields[grouped_on].type === 'selection') { var selection = this.fields[grouped_on].selection, value_lookup = _.where(selection, {0:value}); - group.attributes.value = value_lookup ? value_lookup[0][1] : 'undefined'; + group.attributes.value = value_lookup ? value_lookup[0][1] : _t('undefined'); } else if (value instanceof Array) { group.attributes.value = value[1]; } |
