Anto has proposed merging lp:~openerp-dev/openerp-web/trunk-timeago_i18n-abo 
into lp:openerp-web.

Requested reviews:
  OpenERP R&D Web Team (openerp-dev-web)

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-timeago_i18n-abo/+merge/111885

Introduce a better i18n support for timeago.js.

A pull request has been made on the original project.  You can check it out 
over here: https://github.com/rmm5t/jquery-timeago/pull/83
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-timeago_i18n-abo/+merge/111885
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/trunk-timeago_i18n-abo.
=== modified file 'addons/web/i18n/fr.po'
--- addons/web/i18n/fr.po	2012-06-25 13:52:15 +0000
+++ addons/web/i18n/fr.po	2012-06-25 16:17:21 +0000
@@ -1556,3 +1556,47 @@
 #: addons/web/static/src/xml/base.xml:1823
 msgid "OpenERP.com"
 msgstr "OpenERP.com"
+
+#. openerp-web
+msgid "less than a minute ago"
+msgstr "Il y a moins d'une minute"
+
+#. openerp-web
+msgid "about a minute ago"
+msgstr "Il y a une minute"
+
+#. openerp-web
+msgid "%d minutes ago"
+msgstr "Il y a %d minutes"
+
+#. openerp-web
+msgid "about an hour ago"
+msgstr "Il y a une heure"
+
+#. openerp-web
+msgid "%d hours ago"
+msgstr "Il y a %d heures"
+
+#. openerp-web
+msgid "a day ago"
+msgstr "Il y a un jour"
+
+#. openerp-web
+msgid "%d days ago"
+msgstr "Il y a %d jours"
+
+#. openerp-web
+msgid "about a month ago"
+msgstr "Il y a un mois"
+
+#. openerp-web
+msgid "%d months ago"
+msgstr "Il y a %d mois"
+
+#. openerp-web
+msgid "about a year ago"
+msgstr "Il y a un an"
+
+#. openerp-web
+msgid "%d years ago"
+msgstr "Il y a %d ans"

=== modified file 'addons/web/static/lib/jquery.timeago/jquery.timeago.js'
--- addons/web/static/lib/jquery.timeago/jquery.timeago.js	2012-06-21 22:14:15 +0000
+++ addons/web/static/lib/jquery.timeago/jquery.timeago.js	2012-06-25 16:17:21 +0000
@@ -1,6 +1,9 @@
 /**
  * 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 +52,8 @@
         years: "%d years",
         wordSeparator: " ",
         numbers: []
-      }
+      },
+      translator: null
     },
     inWords: function(distanceMillis) {
       var $l = this.settings.strings;
@@ -70,8 +74,9 @@
 
       function substitute(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 stringAndNumber = {'string': string, 'value': ($l.numbers && $l.numbers[number]) || number};
       }
 
       var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
@@ -85,9 +90,18 @@
         days < 365 && substitute($l.months, Math.round(days / 30)) ||
         years < 1.5 && substitute($l.year, 1) ||
         substitute($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);

=== modified file 'addons/web/static/src/js/coresetup.js'
--- addons/web/static/src/js/coresetup.js	2012-06-25 13:52:15 +0000
+++ addons/web/static/src/js/coresetup.js	2012-06-25 16:17:21 +0000
@@ -606,12 +606,7 @@
 
 /** 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);
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to