From cc2d116e47e27eccc00ec215c3fe3ef1f65f13cb Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Mon, 25 Jun 2012 17:35:45 +0200 Subject: [IMP] better integration of openerp's i18n in timeago.js a suggestion for easier third party i18n integration will be made on the original project's git repo: https://github.com/rmm5t/jquery-timeago bzr revid: abo@openerp.com-20120625153545-zca7qljrizugxntk --- addons/web/static/src/js/coresetup.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 99e134e7bd4..ace41234e0c 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -606,12 +606,7 @@ 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); - } - }); + $.timeago.settings.translator = instance.web._t; } instance.connection.on('module_loaded', this, timeago_setup); -- cgit v1.2.3 From 21cf7115be08aa00ed98bb33e753316737a8a8b6 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 28 Jun 2012 15:33:53 +0200 Subject: [IMP] make the strings composed by timeago.js easy to spot for launchpad rosetta by explicitly calling _t() method on them bzr revid: abo@openerp.com-20120628133353-7dx34sktz9eh3xxd --- addons/web/static/src/js/coresetup.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'addons/web/static/src/js/coresetup.js') diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index ace41234e0c..b599a543055 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -606,7 +606,28 @@ instance.web.qweb.preprocess_node = function() { /** Setup jQuery timeago */ var timeago_setup = function () { + // provide timeago.js with our own translator method $.timeago.settings.translator = instance.web._t; + + /* + * Strings in timeago are "composed" with prefixes, words and suffixes. + * This makes their detection by the translating system pretty much + * imposible, so we'll declare those which will be used in a more explicit + * way. + */ + var timeAgoStrings = [ + instance.web._t('less than a minute ago'), + instance.web._t('about a minute ago'), + instance.web._t('%d minutes ago'), + instance.web._t('about an hour ago'), + instance.web._t('%d hours ago'), + instance.web._t('a day ago'), + instance.web._t('%d days ago'), + instance.web._t('about a month ago'), + instance.web._t('%d months ago'), + instance.web._t('about a year ago'), + instance.web._t('%d years ago'), + ]; } instance.connection.on('module_loaded', this, timeago_setup); -- cgit v1.2.3