Module:ConvertDigit

विकिपिडिया नं
Jump to navigation Jump to search

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

-- First, define a table of text to search for, and what to convert it to.

local conversionTable = {
   ['January'] = 'ज्यानुवरी',
   ['February'] = 'फेब्रुवरी',
   ['March'] = 'मार्च',
   ['April'] = 'एप्रिल',
   ['May'] = 'मे',
   ['June'] = 'जुन',
   ['July'] = 'जुलाइ',
   ['August'] = 'अगस्त',
   ['September'] = 'सेप्तेम्बर',
   ['October'] = 'अक्तोबर',
   ['November'] = 'नोभेम्बर',
   ['December'] = 'दिसेम्बर',
   ['0'] = '०',
   ['1'] = '१',
   ['2'] = '२',
   ['3'] = '३',
   ['4'] = '४',
   ['5'] = '५',
   ['6'] = '६',
   ['7'] = '७',
   ['8'] = '८',
   ['9'] = '९',
}

-- Then we define a table to hold our function
local p = {}

-- Then we define a function that converts strings using conversionTable.
function p.main(frame)
    local s = frame.args[1] -- This gets the first positional argument.
    for en, bn in pairs(conversionTable) 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

return p -- Pass our table containing our function back to Lua.
-- Now we can call our function using {{#invoke:ConvertDigit|main|<!-- your text here 

-->}}.