Module:ConvertDigit
Appearance
Documentation for this module may be created at Module:ConvertDigit/doc
local p = {}
-- First, define a table of text to search for, and what to convert it to.
local conversionTable = { ['0'] = '꯰', ['1'] = '꯱', ['2'] = '꯲', ['3'] = '꯳', ['4'] = '꯴', ['5'] = '꯵', ['6'] = '꯶', ['7'] = '꯷', ['8'] = '꯸', ['9'] = '꯹' }
local versionconTable = { ['꯰'] = '0', ['꯱'] = '1', ['꯲'] = '2', ['꯳'] = '3', ['꯴'] = '4', ['꯵'] = '5', ['꯶'] = '6', ['꯷'] = '7', ['꯸'] = '8', ['꯹'] = '9' }
-- Then we define a function that converts strings using conversionTable.
local function conv(s, t)
for en, bn in pairs(t) do -- This converts every string found in the table.
s = mw.ustring.gsub(s, en, bn)
end
return s -- Get the result of the function.
end
-- Use {{#invoke:ConvertDigit|main|<!--your text with Latin digits->}} to get Meetei Mayek digits.
function p.main(frame)
local s = frame.args[1] -- This gets the first positional argument.
return conv(s, conversionTable)
end
-- Use {{#invoke:ConvertDigit|inverse|<!--your text with Meetei Mayek digits-->}} to get Latin digits.
function p.inverse(frame)
local s = frame.args[1] -- This gets the first positional argument.
return conv(s, versionconTable)
end
return p