ماڈیوٗل:ConvertDigitDevanagari
Appearance
"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ ماڈیوٗل:ConvertDigitDevanagari/دَستاویز جاے بَناونہٕ"
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 Kashmiri Devanagari 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 Kashmiri Devanagari 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