Module:Month translator/data: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 7:
]]
 
local langs = {'ar', 'ca', 'da', 'de', 'es', 'fi', 'fr', 'it', 'nb', 'pl', 'pt', 'ru', 'sv', 'tr'};
 
 
Line 21:
--[[--------------------------< P A T T E R N S >--------------------------------------------------------------
 
table of tables that hold pattern and other information used to extract date parts for translation and reconstrutionreconstruction
 
Tables have the form:
Line 36:
local patterns = {
{'^(%d%d?) +(%a+) +(%d%d%d%d%a?)$', 'd', 'm', 'y'}, -- dd Mmm yyyy
{'^(%d%d?)%. +(%a+) +(%d%d%d%d%a?)$', 'd', 'm', 'y'}, -- dd. Mmm yyyy – for Danish
{'^(%d%d?) +de +(%a+) +de +(%d%d%d%d%a?)$', 'd', 'm', 'y'}, -- dd de Mmm de yyyy
{'^(%a+) +(%d%d%d%d%a?)$', 'm', 'y'}, -- Mmm yyyy
Line 66:
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.
 
To dump this table: =mw.dumpObject (p.month_names_t)
 
]]
Line 80 ⟶ 82:
lang_obj = mw.getLanguage (lang); -- make a language object for the current language
for i, en_month in ipairs (en_months_t) do -- spin through the English month-names table
local index_nameen_date = mw.ustring.lower (lang_obj:formatDate('F', '1 ' .. en_month)); -- ustring requred for tr February (Şubat)
local month_name = mw.ustring.lower (lang_obj:formatDate('F', en_date)); -- translate the English date '1 <en month>' to <month_name>; ustring requred for tr February (Şubat)
month_names_t[index_name] = en_month; -- translate the English name to the current language and store in the translations table; first day of month required
-- month_names_t[lang_obj:formatDate('F', '1 ' ..en_month):lower()month_name] = en_month; -- translate the English nameadd to the current language and store in the translations table; first day of month required
 
if 'pl' == lang then -- for polishpl and other languages that have nominative and genitive forms
month_names_t[lang_obj:formatDate('xg', en_month):lower()] = en_month; -- translate English to genitive form and save
month_name = mw.ustring.lower (lang_obj:formatDate('xg', en_date)); -- translate the English date '1 <en month>' to <month_name> (genitive form)
end
month_names_t[month_name] = en_month; -- add to translations table; when 'xg' is same as 'F', this overwrites the 'F' month name
end
end