summaryrefslogtreecommitdiff
path: root/src/zope/i18n/format.py
diff options
context:
space:
mode:
authorSouheil CHELFOUH <trollfot@gmail.com>2018-09-06 12:59:53 +0200
committerSouheil CHELFOUH <trollfot@gmail.com>2018-09-06 12:59:53 +0200
commitcff01f73c0c9b30b2b32bb319deac4cbe5d1c6a6 (patch)
tree43a1fef79509fb4f79b2cec4396bed8c87aa6067 /src/zope/i18n/format.py
parentdafecabd80e3b9cda4fd96751479853361bb14be (diff)
downloadzope-i18n-cff01f73c0c9b30b2b32bb319deac4cbe5d1c6a6.tar.gz
Added plural capabilities to the different translate methods. It echoes the changes made in the zope.i18nmessageid. This needs heavy testing. Also started to clean up the code to match pep8 recommandations.
Diffstat (limited to 'src/zope/i18n/format.py')
-rw-r--r--src/zope/i18n/format.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/zope/i18n/format.py b/src/zope/i18n/format.py
index ee2e239..96f5ef3 100644
--- a/src/zope/i18n/format.py
+++ b/src/zope/i18n/format.py
@@ -33,6 +33,7 @@ try:
except NameError:
pass # Py3
+
def roundHalfUp(n):
"""Works like round() in python2.x
@@ -42,18 +43,20 @@ def roundHalfUp(n):
"""
return math.floor(n + math.copysign(0.5, n))
+
def _findFormattingCharacterInPattern(char, pattern):
return [entry for entry in pattern
if isinstance(entry, tuple) and entry[0] == char]
+
class DateTimeParseError(Exception):
"""Error is raised when parsing of datetime failed."""
+
@implementer(IDateTimeFormat)
class DateTimeFormat(object):
__doc__ = IDateTimeFormat.__doc__
-
_DATETIMECHARS = "aGyMdEDFwWhHmsSkKz"
calendar = None
@@ -486,11 +489,11 @@ class NumberFormat(object):
return text_type(text)
-
DEFAULT = 0
IN_QUOTE = 1
IN_DATETIMEFIELD = 2
+
class DateTimePatternParseError(Exception):
"""DateTime Pattern Parse Error"""
@@ -760,6 +763,7 @@ SUFFIX = 7
PADDING4 = 8
GROUPING = 9
+
class NumberPatternParseError(Exception):
"""Number Pattern Parse Error"""