Module:User:Awesomemeeos
From EverybodyWiki Bios & Wiki
Documentation for this module may be created at Module:User:Awesomemeeos/doc
local export = {}
local gsub = mw.ustring.gsub
local numerals = {
["0"] = "không", ["1"] = "một", ["2"] = "hai", ["3"] = "ba", ["4"] = "bốn", ["5"] = "năm", ["6"] = "sáu", ["7"] = "bảy", ["8"] = "tám", ["9"] = "chín"
}
function export.result(text)
if type(text) == "table" then
text = text.args[1]
end
text = gsub(text, "1[245]", {
-- ["12"] = "một tá",
-- ["14"] = "mười tư",
["15"] = "mười lăm" })
text = gsub(text, "2[145]", {
["21"] = "hai mươi mốt",
["24"] = "hai mươi tư",
["25"] = "hai mươi lăm" })
text = gsub(text, "([1-9]+)0", "%1")
text = gsub(text, "1([1-9])", "mười %1")
text = gsub(text, "([25])([1-9])", "%1 mươi %2")
text = gsub(text, "([3-9])([1-9])", "%1 mười %2")
text = gsub(text, ".", numerals)
return text
end
return export
