Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorklevin.gluo <klevin.gluo@gmail.com>2013-12-01 19:20:20 (GMT)
committer klevin.gluo <klevin.gluo@gmail.com>2013-12-01 19:20:20 (GMT)
commit77a1c2cb4ed53d494f994781a7d4f7e4736930c5 (patch)
tree8739ad3df00e51849d966d12b88e1a0adcbe9610
parent8cdb7ec26e01ce586893c6cf46bdb78aad337a51 (diff)
fixed so indic numerals are active in arabic locales
-rw-r--r--numParser.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/numParser.py b/numParser.py
index 71f9c1c..5ba0e59 100644
--- a/numParser.py
+++ b/numParser.py
@@ -1,27 +1,34 @@
# -*- coding: UTF-8 -*-
import os
-locale = os.getenv('LANG', u'no language')
+locale = os.getenv('LANG', u'en_US.utf8')
-pashto = {u'۰': u'0', u'۱': u'1', u'۲': u'2', u'۳': u'3', u'۴': u'4', u'۵': u'5', u'۶': u'6', u'۷': u'7', u'۸': u'8', u'۹': u'9'}
-arabic = {v:k for k, v in pashto.items()}
+indic = {u'۰': u'0', u'۱': u'1', u'۲': u'2', u'۳': u'3', u'۴': u'4', u'۵': u'5', u'۶': u'6', u'۷': u'7', u'۸': u'8', u'۹': u'9'}
+arabic = {u'0': u'0', u'1': u'1', u'2': u'2', u'3': u'3', u'4': u'4', u'5': u'5', u'6': u'6', u'7': u'7', u'8': u'8', u'9': u'9',}
+if locale[0:3] in {'ar_'}:
+ localDic = indic
+else:
+ localDic = arabic
-def local(arabicString):
+standardDic = {v:k for k, v in localDic.items()}
+
+
+def local(standardString):
result = u''
- for c in arabicString:
- if c.encode('utf-8') in arabic:
- result = result + arabic[c]
+ for c in standardString:
+ if c.encode('utf-8') in standardDic:
+ result = result + standardDic[c]
else:
result = result + c
return result
-def standard(pashtoString):
- pashtoString = pashtoString.decode('utf-8')
+def standard(localString):
+ localString = localString.decode('utf-8')
result = u''
- for c in pashtoString:
- if c in pashto:
- result = result + pashto[c]
+ for c in localString:
+ if c in localDic:
+ result = result + localDic[c]
else:
result = result + c
return result