diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-07-11 13:29:59 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-07-11 13:29:59 +0200 |
| commit | e431cda2d34f3ff066722232c52bd3987e973b7b (patch) | |
| tree | 5dfe24e9dfd9f351aea9fcb67d7b92670950b2f3 /addons/web/static/src/js/coresetup.js | |
| parent | 3efc9c033a7f9b2a1d032951785ff5a94ecdbe6c (diff) | |
| parent | f419cb8e024ea6a8713091714f940f2ffddf150e (diff) | |
[MERGE} from trunk
bzr revid: xmo@openerp.com-20120711112959-tcb9epdfc9frt6ux
Diffstat (limited to 'addons/web/static/src/js/coresetup.js')
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 99e134e7bd4..a00ca4002e5 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -334,11 +334,14 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess .appendTo(document.body) .load(function () { try { - if (options.error) { - options.error(JSON.parse( - this.contentDocument.body.childNodes[1].textContent - )); - } + if (options.error) { + if (!this.contentDocument.body.childNodes[1]) { + options.error(this.contentDocument.body.childNodes); + } + else { + options.error(JSON.parse(this.contentDocument.body.childNodes[1].textContent)); + } + } } finally { complete(); } @@ -595,7 +598,7 @@ instance.web.qweb.preprocess_node = function() { break; case 1: // Element - var attr, attrs = ['label', 'title', 'alt']; + var attr, attrs = ['label', 'title', 'alt', 'placeholder']; while (attr = attrs.pop()) { if (this.attributes[attr]) { this.attributes[attr] = instance.web._t(this.attributes[attr]); @@ -605,15 +608,31 @@ instance.web.qweb.preprocess_node = function() { }; /** Setup jQuery timeago */ -var timeago_setup = function () { - var s = $.timeago.settings.strings; - _.each(s, function(v,k) { - if(_.isString(v)) { - s[k] = instance.web._t(v); - } - }); +var _t = instance.web._t; +/* + * Strings in timeago are "composed" with prefixes, words and suffixes. This + * makes their detection by our translating system impossible. Use all literal + * strings we're using with a translation mark here so the extractor can do its + * job. + */ +{ + _t('less than a minute ago'); + _t('about a minute ago'); + _t('%d minutes ago'); + _t('about an hour ago'); + _t('%d hours ago'); + _t('a day ago'); + _t('%d days ago'); + _t('about a month ago'); + _t('%d months ago'); + _t('about a year ago'); + _t('%d years ago'); } -instance.connection.on('module_loaded', this, timeago_setup); + +instance.connection.on('module_loaded', this, function () { + // provide timeago.js with our own translator method + $.timeago.settings.translator = instance.web._t; +}); /** * Registry for all the client actions key: tag value: widget |
