مۆدیوول:ConvertTime

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
بەڵگەدارکردنی مۆدیوول[دروست بکە]
-- 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 ckb, en in pairs(conversionTable) do -- This converts every string found in the table.
        s = mw.ustring.gsub(s, ckb, 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 -->}}.