יחידה:Citation/CS1: הבדלים בין גרסאות בדף
מ fix date format |
מ 111 גרסאות של הדף wikipedia:he:יחידה:Citation/CS1 יובאו |
||
| (14 גרסאות ביניים של 3 משתמשים אינן מוצגות) | |||
| שורה 8: | שורה 8: | ||
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance | properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance | ||
} | } | ||
function local_date( | |||
return mw.getContentLanguage():formatDate(format, | |||
function local_date( date_string, format ) | |||
if format==nil then | |||
if date_string:match("^%d%d%d%d%-%d%d%-%d%d$") then --year month day format | |||
format = 'j xg Y' | |||
elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month day, year | |||
format = 'j xg Y' | |||
elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-initial: day month year | |||
format = 'j xg Y' | |||
elseif date_string:match("^%a+ +%d%d%d%d%a?$") then -- month/season year | |||
format='F Y' | |||
--list of accepted formats derived from Citation/CS1/Date validation - in case we may want to localize them later | |||
--elseif date_string:match("^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial day range: month day–day, year; days are separated by endash | |||
--elseif date_string:match("^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-range-initial: day–day month year; days are separated by endash | |||
--elseif date_string:match("^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-range: day month - day month year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$") then -- month initial month-day-range: month day – month day, year; uses spaced endash | |||
--elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-year-range: day month year - day month year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month initial month-day-year-range: month day, year – month day, year; uses spaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d–%d%d%a?$") then -- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$") then -- special case Winter/Summer year-year; year separated with unspaced endash | |||
--elseif date_string:match("^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$") then -- month/season year - month/season year; separated by spaced endash | |||
--elseif date_string:match ("^%a+–%a+ +[1-9]%d%d%d%a?$") then -- month/season range year; months separated by endash | |||
--elseif date_string:match("^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$") then -- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999 | |||
--elseif date_string:match("^[1-9]%d%d%d–%d%d%a?$") then -- Year range: YYYY–YY; separated by unspaced endash | |||
--elseif date_string:match("^[1-9]%d%d%d?%a?$") then -- year; here accept either YYY or YYYY | |||
else | |||
--return date_string | |||
error('Unsupported format') | |||
end | |||
end | |||
return mw.getContentLanguage():formatDate(format, date_string) | |||
end | end | ||
| שורה 168: | שורה 199: | ||
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then | elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then | ||
-- avoid italics for hebrew script | -- avoid italics for hebrew script | ||
if (is_set(lang) and lang == 'he' ) then | local isHebrew = mw.ustring.find( str, '[א-ת]' ) | ||
if (is_set(lang) and lang == 'he') or (isHebrew~=nil) then | |||
return str | return str | ||
else | else | ||
| שורה 653: | שורה 685: | ||
]] | ]] | ||
function pmc(id, embargo) | function pmc(id, embargo) | ||
local test_limit = | local test_limit = 6000000; -- update this value as PMCs approach | ||
local handler = cfg.id_handlers['PMC']; | local handler = cfg.id_handlers['PMC']; | ||
local err_cat = ''; -- presume that PMC is valid | local err_cat = ''; -- presume that PMC is valid | ||
| שורה 1,014: | שורה 1,046: | ||
return str; | return str; | ||
else | else | ||
if str:sub(1,1) == "'" then str = "<span />" .. str; end | if str:sub(1,1) == "'" then str = "<span></span>" .. str; end | ||
if str:sub(-1,-1) == "'" then str = str .. "<span />"; end | if str:sub(-1,-1) == "'" then str = str .. "<span></span>"; end | ||
-- Remove newlines as they break italics. | -- Remove newlines as they break italics. | ||
| שורה 1,527: | שורה 1,559: | ||
-- our part | -- our part | ||
if name == ' | if name == 'ויאטנמית' | ||
then name = ' | then name = 'וייטנאמית' | ||
end | end | ||
-- our part end | -- our part end | ||
| שורה 1,542: | שורה 1,574: | ||
function restoreDate(inputDate) | function restoreDate(inputDate) | ||
return inputDate | |||
-- Until the problem of Month-Year -> Fill Current day will be resolved | |||
-- if inputDate == "" then | |||
-- return "" | |||
-- end | |||
-- return mw.text.trim(globalframe:expandTemplate({title = "זמןמ", args = {'', inputDate, ["שגיאה"] = "ללא"}})); | |||
end | end | ||
| שורה 1,665: | שורה 1,699: | ||
-- our code start | -- our code start | ||
local Month = A['Month']; | local Month = A['Month']; | ||
LangCode = mw.ustring.gsub( Language, '-.*', '' ); | |||
Language = LangCode; | |||
-- our code end | -- our code end | ||
| שורה 1,679: | שורה 1,715: | ||
local IsValidDate, LocalDate | local IsValidDate, LocalDate | ||
local DateFormat = | local DateFormat = nil | ||
-- Set postscript default. | -- Set postscript default. | ||
if not is_set (PostScript) then -- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and | if not is_set (PostScript) then -- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and | ||
| שורה 2,276: | שורה 2,312: | ||
if is_set(AccessDate) then | if is_set(AccessDate) then | ||
local retrv_text = " " .. cfg.messages['retrieved'] | local retrv_text = " " .. cfg.messages['retrieved'] | ||
is_accesssdate_ok, AccessDateParsed = pcall(local_date, AccessDate) -- local canonical format for dates | is_accesssdate_ok, AccessDateParsed = pcall(local_date, AccessDate, 'j xg Y') -- local canonical format for dates | ||
if is_accesssdate_ok then | if is_accesssdate_ok then | ||
AccessDate= AccessDateParsed | AccessDate= AccessDateParsed | ||