diff options
| author | Paramjit Singh Sahota <psa@tinyerp.com> | 2012-07-09 14:26:35 +0530 |
|---|---|---|
| committer | Paramjit Singh Sahota <psa@tinyerp.com> | 2012-07-09 14:26:35 +0530 |
| commit | 2774263ddda67b6983d1c00a04da00e18ff53b85 (patch) | |
| tree | 3b2a8ec5fdccacc2983905f191167d5efdfeddc3 /addons/web/static/src/js/coresetup.js | |
| parent | 202238473c6eb90e539028d553265eb1ec43c87a (diff) | |
| parent | 4d2255a2b3390653f58a17502f7be37b5ec15089 (diff) | |
[MERGE] Merged from openerp-web.
bzr revid: psa@tinyerp.com-20120709085635-g0tcm7nlqe7wd3n3
Diffstat (limited to 'addons/web/static/src/js/coresetup.js')
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 955a46e6923..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(); } @@ -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 |
