Module:Month translator/data: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 7:
]]
 
local langs = {'ca', 'da', 'de', 'es', 'fi', 'fr', 'it', 'nonb', 'pl', 'pt', 'ru', 'sv', 'tr'};
 
 
Line 16:
]]
 
local en_monthsen_months_t = {};
 
 
Line 61:
 
creates a translation table of non-English month names listed in lang{} mapped to English month names listed in
en_months{}<en_months_t> (which this function also fills).
 
lang_obj:formatDate() must be given a day in addition to <en_month> else it will use the current day so, if today
is 31 August 2021, without the expicit '1' preceding the month from <en_month>, when creating a translation for
February, April, June, September, or October lang_obj:formatDate() will return the 'next' month.
 
]]
 
local function month_names_get ()
local month_namesmonth_names_t = {};
 
local lang_obj = mw.language.getContentLanguage(); -- make a language object for the local language
for i=1, 12 do -- loop 12x and
en_monthsen_months_t[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
lang_obj = mw.getLanguage (lang); -- make a language object for the current language
for i, en_month in ipairs (en_monthsen_months_t) do -- spin through the English month-names table
month_namesmonth_names_t[lang_obj:formatDate('F', '1 ' ..en_month):lower()] = en_month; -- translate the English name to the current language and store in the translations table; first day of month required
if 'pl' == lang then -- for polish and other languages that have nominative and genitive forms
month_namesmonth_names_t[lang_obj:formatDate('xg', en_month):lower()] = en_month; -- translate English to genitive form and save
end
end
end
 
return month_namesmonth_names_t;
end
 
Line 90 ⟶ 95:
 
return {
month_namesmonth_names_t = month_names_get (),
override_names = override_names,
patterns = patterns,