Jump to content

Module:Wp/syl/ConvertDigit

From Wikimedia Incubator

Documentation for this module may be created at Module:Wp/syl/ConvertDigit/doc

-- Return input text after converting any en digits and month names.

local en_digits = {
	['0'] = '০',
	['1'] = '১',
	['2'] = '২',
	['3'] = '৩',
	['4'] = '৪',
	['5'] = '৫',
	['6'] = '৬',
	['7'] = '৭',
	['8'] = '৮',
	['9'] = '৯',
}

local en_months = {
	['January'] = 'ꠎꠣꠘꠃꠀꠞꠤ',
	['january'] = 'ꠎꠣꠘꠃꠀꠞꠤ',
	['February'] = 'ꠚꠦꠛꠃꠀꠞꠤ',
	['february'] = 'ꠚꠦꠛꠃꠀꠞꠤ',
	['March'] = 'ꠝꠣꠞ꠆ꠌ',
	['march'] = 'ꠝꠣꠞ꠆ꠌ',
	['April'] = 'ꠄꠙ꠆ꠞꠤꠟ',
	['april'] = 'ꠄꠙ꠆ꠞꠤꠟ',
	['May'] = 'ꠝꠦ',
	['may'] = 'ꠝꠦ',
	['June'] = 'ꠎꠥꠘ',
	['june'] = 'ꠎꠥꠘ',
	['July'] = 'ꠎꠥꠟꠣꠁ',
	['july'] = 'ꠎꠥꠟꠣꠁ',
	['August'] = 'ꠀꠉꠡꠐ',
	['august'] = 'ꠀꠉꠡꠐ',
	['September'] = 'ꠍꠦꠙꠐꠦꠝꠛꠞ',
	['september'] = 'ꠍꠦꠙꠐꠦꠝꠛꠞ',
	['October'] = 'ꠅꠇꠐꠥꠛꠞ',
	['october'] = 'ꠅꠇꠐꠥꠛꠞ',
	['November'] = 'ꠘꠜꠦꠝꠛꠞ',
	['november'] = 'ꠘꠜꠦꠝꠛꠞ',
	['December'] = 'ꠒꠤꠡꠦꠝꠛꠞ',
	['december'] = 'ꠒꠤꠡꠦꠝꠛꠞ',
	['জানুয়ারি'] = 'ꠎꠣꠘꠃꠀꠞꠤ',
	['ফেব্রুয়ারি'] = 'ꠚꠦꠛꠃꠀꠞꠤ',
	['মার্চ'] = 'ꠝꠣꠞ꠆ꠌ',
	['এপ্রিল'] = 'ꠄꠙ꠆ꠞꠤꠟ',
	['মে'] = 'ꠝꠦ',
	['জুন'] = 'ꠎꠥꠘ',
	['জুলাই'] = 'ꠎꠥꠟꠣꠁ',
	['আগস্ট'] = 'ꠀꠉꠡꠐ',
	['সেপ্টেম্বর'] = 'ꠍꠦꠙꠐꠦꠝꠛꠞ',
	['অক্টোবর'] = 'ꠅꠇꠐꠥꠛꠞ',
	['নভেম্বর'] = 'ꠘꠜꠦꠝꠛꠞ',
	['ডিসেম্বর'] = 'ꠒꠤꠡꠦꠝꠛꠞ',
}

local function _main(input)
	-- Callable from another module.
	input = input or ''
	return (input:gsub('%a+', en_months):gsub('%d', en_digits))
end

local function main(frame)
	-- Callable from #invoke or from a template.
	return _main(frame.args[1] or frame:getParent().args[1])
end

return { main = main, _main = _main }