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/lib | |
| parent | 202238473c6eb90e539028d553265eb1ec43c87a (diff) | |
| parent | 4d2255a2b3390653f58a17502f7be37b5ec15089 (diff) | |
[MERGE] Merged from openerp-web.
bzr revid: psa@tinyerp.com-20120709085635-g0tcm7nlqe7wd3n3
Diffstat (limited to 'addons/web/static/lib')
| -rw-r--r-- | addons/web/static/lib/jquery.timeago/jquery.timeago.js | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/addons/web/static/lib/jquery.timeago/jquery.timeago.js b/addons/web/static/lib/jquery.timeago/jquery.timeago.js index 14177473973..91ba5fd7756 100644 --- a/addons/web/static/lib/jquery.timeago/jquery.timeago.js +++ b/addons/web/static/lib/jquery.timeago/jquery.timeago.js @@ -1,6 +1,8 @@ /** * Timeago is a jQuery plugin that makes it easy to support automatically * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago"). + * + * Please note that the library has been slightly modified for i18n's sake. * * @name timeago * @version 0.11.3 @@ -49,7 +51,8 @@ years: "%d years", wordSeparator: " ", numbers: [] - } + }, + translator: null }, inWords: function(distanceMillis) { var $l = this.settings.strings; @@ -68,26 +71,36 @@ var days = hours / 24; var years = days / 365; - function substitute(stringOrFunction, number) { + function convert(stringOrFunction, number) { var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; - var value = ($l.numbers && $l.numbers[number]) || number; - return string.replace(/%d/i, value); + + // return the proper string and the numeric value that goes in it + return {'string': string, 'value': ($l.numbers && $l.numbers[number]) || number}; } - var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || - seconds < 90 && substitute($l.minute, 1) || - minutes < 45 && substitute($l.minutes, Math.round(minutes)) || - minutes < 90 && substitute($l.hour, 1) || - hours < 24 && substitute($l.hours, Math.round(hours)) || - hours < 42 && substitute($l.day, 1) || - days < 30 && substitute($l.days, Math.round(days)) || - days < 45 && substitute($l.month, 1) || - days < 365 && substitute($l.months, Math.round(days / 30)) || - years < 1.5 && substitute($l.year, 1) || - substitute($l.years, Math.round(years)); + var stringAndNumber = seconds < 45 && convert($l.seconds, Math.round(seconds)) || + seconds < 90 && convert($l.minute, 1) || + minutes < 45 && convert($l.minutes, Math.round(minutes)) || + minutes < 90 && convert($l.hour, 1) || + hours < 24 && convert($l.hours, Math.round(hours)) || + hours < 42 && convert($l.day, 1) || + days < 30 && convert($l.days, Math.round(days)) || + days < 45 && convert($l.month, 1) || + days < 365 && convert($l.months, Math.round(days / 30)) || + years < 1.5 && convert($l.year, 1) || + convert($l.years, Math.round(years)); + var string = stringAndNumber.string; + var value = stringAndNumber.value; var separator = $l.wordSeparator === undefined ? " " : $l.wordSeparator; - return $.trim([prefix, words, suffix].join(separator)); + + // compose and translate the final string + var fullString = $.trim([prefix, string, suffix].join(separator)); + var translatedString = $t.settings.translator ? + $t.settings.translator(fullString) : + fullString; + + return translatedString.replace(/%d/i, value); }, parse: function(iso8601) { var s = $.trim(iso8601); |
