Module:Month translator: Difference between revisions

Content deleted Content added
data tables to ~/data;
No edit summary
Line 24:
if c1 then -- c1 always set on match
t = {
[pattern[2] or 'x'] = c1, -- fill the table of captures with the rest of the captures
[pattern[3] or 'x'] = c2, -- take index names from pattern table and assign sequential captures
[pattern[4] or 'x'] = c3, -- index name may be nil in pattern table so "or 'x'" spoofs a name for this index in this table
Line 30:
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_names[month]; -- replace non-English name with English name from translation tables
year= t.y or '';
 
if month then
if data.month_names[month] then -- look in translation table for non-English month name; TODO: add support for an override table for when MediaWiki is wrong
if 'dmy' == pattern[5] then -- for dmy dates
return table.concat ({day, data.month_names[month], year}, ' '); -- assemble an English language dmy date
elseif 'my' == pattern[5] then -- for month year dates
return table.concat ({data.month_names[month], year}, ' '); -- assemble an English language dmy date
end
end