Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add Persian language #378

Open
mrr-r opened this issue Mar 18, 2021 · 0 comments
Open

Please add Persian language #378

mrr-r opened this issue Mar 18, 2021 · 0 comments

Comments

@mrr-r
Copy link

mrr-r commented Mar 18, 2021

Hello,
Thank you for your module.
Please add to your module Persian language, you can use our symbol with follow code:
unit = {
"0" : "" ,
"1" : "یک" ,
"2" : "دو" ,
"3" : "سه" ,
"4" : "چهار" ,
"5" : "پنج" ,
"6" : "شش" ,
"7" : "هفت" ,
"8" : "هشت" ,
"9" : "نه"}

tens = {
"0" : "" ,
"10" : "ده" ,
"11" : "یازده" ,
"12" : "دوازده" ,
"13" : "سیزده" ,
"14" : "چهارده" ,
"15" : "پانزده" ,
"16" : "شانزده" ,
"17" : "هفده" ,
"18" : "هجده" ,
"19" : "نوزده" ,
"2" : "بیست" ,
"3" : "سی" ,
"4" : "چهل" ,
"5" : "پنجاه" ,
"6" : "شصت" ,
"7" : "هفتاد" ,
"8" : "هشتاد" ,
"9" : "نود"}

hundreds = {
"0" : "" ,
"1" : "یکصد" ,
"2" : "دویست" ,
"3" : "سیصد" ,
"4" : "چهارصد" ,
"5" : "پانصد" ,
"6" : "ششصد" ,
"7" : "هفتصد" ,
"8" : "هشتصد" ,
"9" : "نهصد"
}
prefix =[
"ریال" ,
"هزار و" ,
"میلیون و" ,
"میلیارد و" ,
]

def toalpha(a):
result = []
if len(a) == 1:
result.append(unit.get(a))
if len(a) == 2:
if a[0] == "1":
result.append(tens.get(a[0::]))
else:
result.append(tens.get(a[0]))
result.append(unit.get(a[1]))
if len(a) == 3:
result.append(hundreds.get(a[0]))
if a[1] == "1":
result.append(tens.get(a[1::]))
else:
result.append(tens.get(a[1]))
result.append(unit.get(a[2]))
for a in range(len(result)-1):
if result[a] == "":
result.pop(a)
return " و ".join(result)

def count(b):
res = []
for i in range(ceil(len(b) / 3)):
if len(b)% 3 > 0:
res.append(toalpha(b[0:len(b)% 3:]))
b = b[len(b)% 3:]
else :
res.append(toalpha(b[0:3:]))
b = b[3:]
return res
def main(ta):
total = str(int(ta))
result = count(total)
resultreversed = result[::-1]
final = []
p = ""
for i in range(len(resultreversed)):
final.append(resultreversed[i] + " " + prefix[i])
for i in reversed(final):
p += i
return p

@mrr-r mrr-r changed the title Please add Pesian language Please add Persian language Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant