forked from yilkalargaw/geezify-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeezify.lua
More file actions
64 lines (48 loc) · 1.48 KB
/
geezify.lua
File metadata and controls
64 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
local geezify={}
function geezify.geezify_2digit(num)
local oneth_array = {'', '፩', '፪', '፫', '፬', '፭', '፮', '፯', '፰', '፱'}
local tenth_array = {'', '፲', '፳', '፴', '፵', '፶', '፷', '፸', '፹', '፺'}
local tenth_index = math.floor(num / 10)
local oneth_index = num % 10
return tenth_array[tenth_index+1] .. oneth_array[oneth_index+1]
end
function geezify.geezify_4digit(num)
local first2 = math.floor(num/100)
local second2 = num%100
if first2==0 then
return geezify.geezify_2digit(second2)
else
return geezify.geezify_2digit(first2) ..'፻'.. geezify.geezify_2digit(second2)
end
end
function geezify.split_every_4_digit(num)
local a={}
table.insert(a, string.sub(num,1, string.len(num)%4))
for digits in string.gmatch(string.sub(num,(string.len(num)%4)+1 ,-1) ,"%d%d%d%d") do
table.insert(a , digits)
end
return a
end
function geezify.geezify(num)
local digarr = geezify.split_every_4_digit(num)
local converted= ""
for i,v in ipairs(digarr) do
if i==1 and v=='' then
converted = converted
else
if converted==nil or converted == '' then
converted = (converted or '') .. geezify.geezify_4digit(v)
else
converted = (converted or "") ..'፼'.. geezify.geezify_4digit(v)
end
end
end
local geez_no =
string.gsub(
string.gsub(
string.gsub(converted,'፼፩፻', '፼፻')
,'^፩፼', '፼')
,'^(፩፻)', '፻')
return geez_no
end
return geezify