Module:Citation/CS1/Date validation: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
update per RfC; |
sync from sandbox; |
||
வரிசை 569:
elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then -- special case Winter/Summer year-year; year separated with unspaced endash
month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
anchor_year = year .. '–' .. anchor_year; -- assemble anchor_year from both years▼
return false; -- not Summer or Winter; abandon
end
if 1 ~= tonumber(year2) - tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif mw.ustring.match(date_string, patterns['My-My'][1]) then -- month/season year - month/season year; separated by spaced endash
வரி 915 ⟶ 917:
};
if t.a then -- if this date has an anchor year capture (all convertable date formats except ymd)
t.y2 = t.a; -- use the anchor year capture when reassembling the date
else -- here for single date formats (except ymd)
t.y = t.a; -- use the anchor year capture when reassembling the date
end
end
if tonumber(t.m) then -- if raw month is a number (converting from ymd)
if 's' == mon_len then -- if we are to use abbreviated month names
t.m = cfg.date_names['
else
t.m = cfg.date_names['
end
t.d = t.d:gsub ('0(%d)', '%1'); -- strip leading '0' from day if present
வரி 938 ⟶ 944:
t[mon] = get_month_number (t[mon]); -- get the month number for this month (is length agnostic)
if 0 == t[mon] then return; end -- seasons and named dates can't be converted
t[mon] = (('s' == mon_len) and cfg.date_names['
end
end
வரி 1,057 ⟶ 1,063:
--[[-------------------------< D A T E _ N A M E _ X L A T E >------------------------------------------------
Attempts to translate English
date parser function. This is simple name-for-name replacement and may not work for all languages.
வரி 1,071 ⟶ 1,077:
local date;
local sources_t = {
{cfg.date_names.en.long, cfg.date_names.inv_local_long}, -- for translating long English month names to long local month names
{cfg.date_names.en.short, cfg.date_names.inv_local_short}, -- short month names
{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter}, -- quarter date names
{cfg.date_names.en.season, cfg.date_names.inv_local_season}, -- season date nam
{cfg.date_names.en.named, cfg.date_names.inv_local_named}, -- named dates
}▼
local function is_xlateable (month) -- local function to get local date name that replaces existing English-language date name
for _, date_names_t in ipairs (sources_t) do -- for each sequence table in date_names_t
if date_names_t[1][month] then -- if date name is English month (long or short), quarter, season or named and
if date_names_t[2][date_names_t[1][month]] then -- if there is a matching local date name
return date_names_t[2][date_names_t[1][month]]; -- return the local date name
end
end
end
for param_name, param_val in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if is_set(param_val.val) then -- if the parameter has a value
date = param_val.val;
for month in mw.ustring.gmatch (date, '[%a ]+') do
month = mw.text.trim (month); -- this because quarterly dates contain whitespace
if cfg.date_names.en.long[month] then▼
elseif cfg.date_names.en.short[month] then▼
▲-- if cfg.date_names.en.long[month] then -- long month dates
mode = 'M'; -- English name is short so use short local name▼
-- if cfg.date_names.inv_local_long[cfg.date_names.en.long[month]] then
▲ else
-- xlate = cfg.date_names.inv_local_long[cfg.date_names.en.long[month]];
mode = nil; -- not an English month name; could be local language month name or an English season name▼
-- end
---- mode = 'F'; -- English name is long so use long local name
--
-- if cfg.date_names.inv_local_short[cfg.date_names.en.short[month]] then
xlate = lang_object:formatDate(mode, '1' .. month); -- translate the month name to this local language▼
-- xlate = cfg.date_names.inv_local_short[cfg.date_names.en.short[month]];
-- end
▲---- mode = 'M'; -- English name is short so use short local name
-- elseif cfg.date_names.en.quarter[month] then -- quarter dates
-- if cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]] then
-- xlate = cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]];
-- end
-- elseif cfg.date_names.en.season[month] then -- season dates
-- if cfg.date_names.inv_local_season[cfg.date_names.en.season[month]] then
-- xlate = cfg.date_names.inv_local_season[cfg.date_names.en.season[month]];
-- end
-- if cfg.date_names.inv_local_named[cfg.date_names.en.named[month]] then
-- xlate = cfg.date_names.inv_local_named[cfg.date_names.en.named[month]];
-- end
-- else
-- xlate=nil; -- not an English month name; could be local language month name
▲---- mode = nil; -- not an English month name; could be local language month name or an English season name
-- end
if xlate then
-- if mode then -- might be a season
▲-- xlate = lang_object:formatDate(mode, '1' .. month); -- translate the month name to this local language
date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation
date_parameters_list[param_name].val = date; -- save the translated date
| |||