မာတိကာသို့ ခုန်သွားရန်

မော်ဂျူး:blk-utilities

အဝ်ႏ ဝိစ်သိဉ်နရီ ကို

Documentation for this module may be created at မော်ဂျူး:blk-utilities/doc

local export = {}

local gsub = mw.ustring.gsub
local find = mw.ustring.find
local match = mw.ustring.match
local blk_digits = {"၀", "၁", "၂", "၃", "၄", "၅", "၆", "၇", "၈", "၉"}

function export.pluralize(str)
	return str:find("ဖုံႏ$") and str or str .. "ဖုံႏ"
end

function export.arabic_digit_to_blk(text)
	if type(text) == "number" then
		text = tostring(text) -- convert to string
	end
	if type(text) == "string" and find(text, "[0-9]") then
		for n = 0, 9 do
			text = gsub(text, tostring(n), blk_digits[n + 1])
		end
	end
	return text
end

function export.blk_digit_to_arabic(text)
	if type(text) == "string" and find(text, "[၀-၉]") then
		for n = 0, 9 do
			text = gsub(text, blk_digits[n + 1], tostring(n))
		end
	end
	return text
end

return export