Conversion_Kitchen_Code/kitchen_counter/conversion/translation/transString.py

60 lines
1.5 KiB
Python
Raw Normal View History

2024-04-27 09:33:09 +00:00
#Latin to Arabic
buck2uni = {
"'": u"\u0621",
"|": u"\u0622",
">": u"\u0623",
"&": u"\u0624",
"<": u"\u0625",
"}": u"\u0626",
"A": u"\u0627",
"b": u"\u0628",
"p": u"\u0629",
"t": u"\u062A",
"v": u"\u062B",
"j": u"\u062C",
"H": u"\u062D",
"x": u"\u062E",
"d": u"\u062F",
"*": u"\u0630",
"r": u"\u0631",
"z": u"\u0632",
"s": u"\u0633",
"$": u"\u0634",
"S": u"\u0635",
"D": u"\u0636",
"T": u"\u0637",
"Z": u"\u0638",
"E": u"\u0639", # cayn
"g": u"\u063A", # ghayn
"_": u"\u0640", # taTwiil
"f": u"\u0641", # faa '
"q": u"\u0642", # qaaf
"k": u"\u0643", # kaaf
"l": u"\u0644", # laam
"m": u"\u0645", # miim
"n": u"\u0646", # nuun
"h": u"\u0647", # haa '
"w": u"\u0648", # waaw
"Y": u"\u0649", # 'alif maqSuura
"y": u"\u064A", # yaa '
"F": u"\u064B", # fatHatayn
"N": u"\u064C", # Dammatayn
"K": u"\u064D", # kasratayn
"a": u"\u064E", # fatHa
"u": u"\u064F", # Damma
"i": u"\u0650", # kasra
"~": u"\u0651", # shaddah
"o": u"\u0652", # sukuun
"`": u"\u0670", # dagger 'alif
"{": u"\u0671"
}
def transString(string, reverse = 0):
for k, v in buck2uni.items():
if not reverse:
string = string.replace(v, k)
else :
string = string.replace(k, v)
return string.lower()