词条 | Module:User:Mr. Stradivarius/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 functionlocal 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, bn, 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:User:Mr. Stradivarius/convertTime|main|}}. |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。