Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mathlib.py
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2007-11-13 10:13:57 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2007-11-13 10:13:57 (GMT)
commit3b0b9526b75d167981e4c2aeaa8b298de18c9583 (patch)
tree7fe78eaba745b0c6eb368b688c6d994fdcd1b656 /mathlib.py
parent297422fff90867e20be3cc7d1165c3e4e77ff584 (diff)
Unicode parsing + bugfixes
Diffstat (limited to 'mathlib.py')
-rw-r--r--mathlib.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/mathlib.py b/mathlib.py
index 4d98ad8..ae18780 100644
--- a/mathlib.py
+++ b/mathlib.py
@@ -25,6 +25,8 @@ import random
import logging
_logger = logging.getLogger('MathLib')
+from gettext import gettext as _
+
class MathLib:
ANGLE_DEG = math.pi/180
ANGLE_RAD = 1
@@ -49,6 +51,29 @@ class MathLib:
self.set_constant('c_n', self.parse_number('0')) #neutron properties
self.set_constant('m_n', self.parse_number('1.6749272928e-27'))
+ self.setup_i18n()
+
+ def setup_i18n(self):
+ # The separator to mark thousands (default: ',')
+ self.thousand_sep = _('thousand_sep')
+ if self.thousand_sep == 'thousand_sep':
+ self.thousand_sep = ','
+
+ # The separator to mark fractions (default: '.')
+ self.fraction_sep = _('fraction_sep')
+ if self.fraction_sep == 'fraction_sep':
+ self.fraction_sep = '.'
+
+ # The multiplication symbol (default: '*')
+ self.mul_sym = _('mul_sym')
+ if self.mul_sym == 'mul_sym':
+ self.mul_sym = '*'
+
+ # The division symbol (default: '/')
+ self.div_sym = _('div_sym')
+ if self.div_sym == 'div_sym':
+ self.div_sym = '/'
+
def set_angle_type(self, type):
self.angle_scaling = self.d(type)
_logger.debug('Angle type set to:%s', self.angle_scaling)
@@ -115,9 +140,9 @@ class MathLib:
for i in xrange(len(digits)):
if i == dot_pos:
if i == 0:
- res += '0.'
+ res += '0' + self.fraction_sep
else:
- res += '.'
+ res += self.fraction_sep
res += str(digits[i])
if len(digits) < dot_pos: