ماڈیول:ConvertTime

آزاد انسائیکلوپیڈیا، وکیپیڈیا توں

Documentation for this module may be created at ماڈیول:ConvertTime/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 bn, en in pairs(conversionTable) do -- This converts every string found in the table.
        s = mw.ustring.gsub(s, ur, en)
    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:ConvertTime|main|<!-- your text here -->}}.