Use request locale formatter in "getHumanSize()" function ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Wed, 10 Apr 2013 16:46:12 +0200
branchZTK-1.1
changeset 207 7630f79b1506
parent 206 01b492f1f87e
child 208 3fc0a1057b42
Use request locale formatter in "getHumanSize()" function
docs/HISTORY.txt
src/ztfy/utils/locales/en/LC_MESSAGES/ztfy.utils.mo
src/ztfy/utils/locales/en/LC_MESSAGES/ztfy.utils.po
src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.mo
src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po
src/ztfy/utils/locales/ztfy.utils.pot
src/ztfy/utils/size.py
--- a/docs/HISTORY.txt	Wed Apr 10 16:39:03 2013 +0200
+++ b/docs/HISTORY.txt	Wed Apr 10 16:46:12 2013 +0200
@@ -1,6 +1,10 @@
 Changelog
 =========
 
+0.4.1
+-----
+ - use request locale formatter in getHumanSize function
+
 0.4.0
 -----
  - move custom schema fields widgets to ZTFY.skin package
Binary file src/ztfy/utils/locales/en/LC_MESSAGES/ztfy.utils.mo has changed
--- a/src/ztfy/utils/locales/en/LC_MESSAGES/ztfy.utils.po	Wed Apr 10 16:39:03 2013 +0200
+++ b/src/ztfy/utils/locales/en/LC_MESSAGES/ztfy.utils.po	Wed Apr 10 16:46:12 2013 +0200
@@ -14,7 +14,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: ZTFY.utils\n"
-"POT-Creation-Date: Tue Nov 20 18:05:59 2012\n"
+"POT-Creation-Date: Wed Apr 10 16:36:50 2013\n"
 "PO-Revision-Date: 2009-08-14 18:14+0200\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
Binary file src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.mo has changed
--- a/src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po	Wed Apr 10 16:39:03 2013 +0200
+++ b/src/ztfy/utils/locales/fr/LC_MESSAGES/ztfy.utils.po	Wed Apr 10 16:46:12 2013 +0200
@@ -16,7 +16,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: ZTFY.utils\n"
-"POT-Creation-Date: Tue Nov 20 18:05:59 2012\n"
+"POT-Creation-Date: Wed Apr 10 16:36:50 2013\n"
 "PO-Revision-Date: 2012-03-26 14:18+0200\n"
 "Last-Translator: Thierry Florac <thierry.florac@onf.fr>\n"
 "Language-Team: français <>\n"
@@ -31,15 +31,9 @@
 msgid "-- automatic selection --"
 msgstr "-- sélection automatique --"
 
-#: ztfy/utils/browser/templates/daterange_display.pt:2
-#: ztfy/utils/browser/templates/daterange_input.pt:2
-msgid "Between:"
-msgstr "Entre le :"
-
-#: ztfy/utils/browser/templates/daterange_display.pt:4
-#: ztfy/utils/browser/templates/daterange_input.pt:6
-msgid "and:"
-msgstr "et le :"
+#: ztfy/utils/browser/zodb.py:40
+msgid "ZEO connection properties"
+msgstr "Propriétés de la connexion ZEO"
 
 #: ztfy/utils/date.py:101
 msgid "%d hours ago"
@@ -569,22 +563,34 @@
 msgid "This principal can't be found in any authentication utility..."
 msgstr "Ce mandant ne peut pas être trouvé"
 
-#: ztfy/utils/size.py:37
+#: ztfy/utils/size.py:41
 msgid "%d bytes"
 msgstr "%d octets"
 
-#: ztfy/utils/size.py:40
+#: ztfy/utils/size.py:45
 msgid "%.1f Kb"
 msgstr "%.1f Ko"
 
-#: ztfy/utils/size.py:43
+#: ztfy/utils/size.py:47
+msgid "%s Kb"
+msgstr "%s Ko"
+
+#: ztfy/utils/size.py:51
 msgid "%.2f Mb"
 msgstr "%.2f Mo"
 
-#: ztfy/utils/size.py:45
+#: ztfy/utils/size.py:53
+msgid "%s Mb"
+msgstr "%s Mo"
+
+#: ztfy/utils/size.py:56
 msgid "%.3f Gb"
 msgstr "%.3f Go"
 
+#: ztfy/utils/size.py:58
+msgid "%s Gb"
+msgstr "%s Go"
+
 #: ztfy/utils/timezone/interfaces.py:35
 msgid "Server timezone"
 msgstr "Fuseau horaire"
--- a/src/ztfy/utils/locales/ztfy.utils.pot	Wed Apr 10 16:39:03 2013 +0200
+++ b/src/ztfy/utils/locales/ztfy.utils.pot	Wed Apr 10 16:46:12 2013 +0200
@@ -14,7 +14,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: Meaningless\n"
-"POT-Creation-Date: Tue Nov 20 18:05:59 2012\n"
+"POT-Creation-Date: Wed Apr 10 16:36:50 2013\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: Zope 3 Developers <zope-dev@zope.org>\n"
@@ -27,14 +27,8 @@
 msgid "-- automatic selection --"
 msgstr ""
 
-#: ztfy/utils/browser/templates/daterange_display.pt:2
-#: ztfy/utils/browser/templates/daterange_input.pt:2
-msgid "Between:"
-msgstr ""
-
-#: ztfy/utils/browser/templates/daterange_display.pt:4
-#: ztfy/utils/browser/templates/daterange_input.pt:6
-msgid "and:"
+#: ztfy/utils/browser/zodb.py:40
+msgid "ZEO connection properties"
 msgstr ""
 
 #: ztfy/utils/date.py:101
@@ -557,22 +551,34 @@
 msgid "This principal can't be found in any authentication utility..."
 msgstr ""
 
-#: ztfy/utils/size.py:37
+#: ztfy/utils/size.py:41
 msgid "%d bytes"
 msgstr ""
 
-#: ztfy/utils/size.py:40
+#: ztfy/utils/size.py:45
 msgid "%.1f Kb"
 msgstr ""
 
-#: ztfy/utils/size.py:43
+#: ztfy/utils/size.py:47
+msgid "%s Kb"
+msgstr ""
+
+#: ztfy/utils/size.py:51
 msgid "%.2f Mb"
 msgstr ""
 
-#: ztfy/utils/size.py:45
+#: ztfy/utils/size.py:53
+msgid "%s Mb"
+msgstr ""
+
+#: ztfy/utils/size.py:56
 msgid "%.3f Gb"
 msgstr ""
 
+#: ztfy/utils/size.py:58
+msgid "%s Gb"
+msgstr ""
+
 #: ztfy/utils/timezone/interfaces.py:35
 msgid "Server timezone"
 msgstr ""
--- a/src/ztfy/utils/size.py	Wed Apr 10 16:39:03 2013 +0200
+++ b/src/ztfy/utils/size.py	Wed Apr 10 16:46:12 2013 +0200
@@ -33,13 +33,26 @@
     """Convert given bytes value in human readable format"""
     if request is None:
         request = queryRequest()
+        if request is not None:
+            formatter = request.locale.numbers.getFormatter('decimal')
+        else:
+            formatter = None
     if value < 1024:
         return translate(_("%d bytes"), context=request) % value
     value = value / 1024.0
     if value < 1024:
-        return translate(_("%.1f Kb"), context=request) % value
+        if formatter is None:
+            return translate(_("%.1f Kb"), context=request) % value
+        else:
+            return translate(_("%s Kb"), context=request) % formatter.format(value, '0.0')
     value = value / 1024.0
     if value < 1024:
-        return translate(_("%.2f Mb"), context=request) % value
+        if formatter is None:
+            return translate(_("%.2f Mb"), context=request) % value
+        else:
+            return translate(_("%s Mb"), context=request) % formatter.format(value, '0.00')
     value = value / 1024.0
-    return translate(_("%.3f Gb"), context=request) % value
+    if formatter is None:
+        return translate(_("%.3f Gb"), context=request) % value
+    else:
+        return translate(_("%s Gb"), context=request) % formatter.format(value, '0.000')