Module:Month translator: Difference between revisions

Content deleted Content added
No edit summary
Replace Module:No globals with require( "strict" )
 
(2 intermediate revisions by one other user not shown)
Line 1:
require ('Module:No globalsstrict')
local getArgs = require ('Module:Arguments').getArgs;
 
Line 15:
local day, month, year;
if 'dump' == args_t[1] then -- args_t[1] = 'dump' to dump month_names<month_names_t> table;
return mw.dumpObject (data.month_namesmonth_names_t);
end
if not args_t[1] then return nil end
for i, pattern in ipairs (data.patterns) do -- spin through the patterns table looking for a match
local c1, c2, c3; -- captures in the 'pattern' from the pattern table go here
 
Line 32:
day = t.d or ''; -- translate table contents to named variables;
month = mw.ustring.lower (t.m or ''); -- absent table entries are nil so set unused parts to empty string; lowercase for indexing
month = data.override_names[month] or data.month_namesmonth_names_t[month]; -- replace non-English name with English name from translation tables
year= t.y or '';
 
Line 48:
end
end
break; -- and done; if here found pattern match but did not find non-English month name in month_names{}<month_names_t>
end
end