Module:Month translator/data: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
 
--[[--------------------------< L A N G U A G E S >------------------------------------------------------------
 
Table of ISO 639 codes for languages supported by this module. List of MediaWiki supported languages and their
codes can be found at: Template:Citation_Style_documentation/language/doc
 
]]
 
local langs = {'ca', 'de', 'es', 'fi', 'fr', 'it', 'pl', 'pt', 'sv'};
 
 
local en_months = {'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'};
--[[--------------------------< E N G L I S H M O N T H N A M E S >----------------------------------------
 
Table of local language month names filled by month_names_get()
 
]]
 
local en_months = {};
 
 
Line 14 ⟶ 29:
[3] - same as [2] for the second capture
[4] - same as [2] for the last (right-most) capture
[5] - string identifier that specified the format of the matching date:
'dmy' - day month year
'm' - month only (mostly for debug)
'mdy' - month day, year
'my' - month year
 
ymd numeric dates have no hames so are not translated; use |df= parameter in the cs1|2 template for that.
Line 31 ⟶ 41:
{'^(%a+) +(%d%d?) *, +(%d%d%d%d%a?)$', 'm', 'd', 'y'}, -- Mmm dd, yyyy
{'^(%a+)$', 'm'}, -- month only; mostly for debug purposes
 
-- {'^(%d%d?) +(%a+) +(%d%d%d%d%a?)$', 'd', 'm', 'y', 'dmy'}, -- dd Mmm yyyy
-- {'^(%d%d?) +de +(%a+) +de +(%d%d%d%d%a?)$', 'd', 'm', 'y', 'dmy'}, -- dd de Mmm de yyyy
-- {'^(%a+) +(%d%d%d%d%a?)$', 'm', 'y', nil, 'my'}, -- Mmm yyyy
-- {'^(%a+) +de +(%d%d%d%d%a?)$', 'm', 'y', nil, 'my'}, -- Mmm de yyyy
-- {'^(%a+) +(%d%d?) *, +(%d%d%d%d%a?)$', 'm', 'd', 'y', 'mdy'}, -- Mmm dd, yyyy
-- {'^(%a+)$', 'm', nil, nil, 'm'}, -- month only; mostly for debug purposes
};
 
Line 46 ⟶ 49:
month_names_get(). Items in this list have the form:
['<non-English month name>'] = 'English month name',
'<non-English month name>' must be lowercase
]]
 
Line 51 ⟶ 55:
[''] = '',
}
 
 
--[[--------------------------< M O N T H _ N A M E S _ G E T >------------------------------------------------
 
creates a translation table of non-English month names listed in lang{} mapped to English month names listed in
en_months{}. (which this function also fills).
 
]]
Line 62 ⟶ 67:
local month_names = {};
 
local lang_obj = mw.language.getContentLanguage(); -- make a language object for the local language
for i=1, 12 do -- loop 12x and
en_months[i] = lang_obj:formatDate('F', '2018-' .. i) -- get month names for each i
end
for _, lang in ipairs (langs) do -- spin through the languages table
local lang_obj = mw.getLanguage (lang); -- make a language object for the current language
for i, en_month in ipairs (en_months) do -- spin through the English month-names table
month_names[lang_obj:formatDate('F', en_month):lower()] = en_month; -- translate the English name to the current language and store in the translations table