יחידה:Citation/CS1: הבדלים בין גרסאות בדף

שחזור לגרסה 18440017 מתאריך 17:09, 12 באפריל 2016 מאת IKhitron
מ 111 גרסאות של הדף wikipedia:he:יחידה:Citation/CS1 יובאו
 
(19 גרסאות ביניים של 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( date )
 
return  mw.getContentLanguage():formatDate('j xg Y', date)
 
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
str = safeforitalics( str );
str = '<span dir="auto">'..safeforitalics( str )..'</span>';
end
end
end
end
שורה 212: שורה 244:
-- our code
-- our code
if is_set (transchapter) then
if is_set (transchapter) then
transchapter = '<span class="mw-content-rtl">' .. transchapter .. "</span>&lrm;";
transchapter = '<span class="mw-content-rtl">' .. transchapter .. "</span>";
end
end
-- our code end
-- our code end
שורה 653: שורה 685:
]]
]]
function pmc(id, embargo)
function pmc(id, embargo)
local test_limit = 5000000; -- update this value as PMCs approach
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,045: שורה 1,077:
for _, value in ipairs( tbl ) do
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if value == nil then value = ''; end
value = '&lrm;' .. value .. '&lrm;'
if str == '' then
if str == '' then
str = value;
str = value;
שורה 1,499: שורה 1,530:
local test='';
local test='';
if 0 == namespace and (('he' == lang:lower()) or ('hebrew' == lang:lower())) then
-- if 0 == namespace and (('he' == lang:lower()) or ('hebrew' == lang:lower())) then
table.insert (z.maintenance_cats, 'תבנית ציטוט עם ציון עברית בתור שפה זרה'); -- add maintenance category if |language=Hebrew or |language=he in article space
-- table.insert (z.maintenance_cats, 'תבנית ציטוט עם ציון עברית בתור שפה זרה'); -- add maintenance category if |language=Hebrew or |language=he in article space
end
-- end


if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
שורה 1,528: שורה 1,559:


-- our part
-- our part
if name == 'נורבגית'
if name == 'ויאטנמית'
   then name = 'נורווגית'
   then name = 'וייטנאמית'
   end
   end
-- our part end
-- our part end
שורה 1,543: שורה 1,574:


function restoreDate(inputDate)
function restoreDate(inputDate)
if inputDate == "" then
return inputDate
return ""
-- 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
 
function autoDir(str)
if str and str ~= '' then
return '<span dir="auto">' ..str .. '</span>'
end
end
-- error("a"..mw.text.trim(globalframe:expandTemplate({title = "זמןמ", args = {'', inputDate, error = "ללא"}})).."a")
return str
return mw.text.trim(globalframe:expandTemplate({title = "זמןמ", args = {'', inputDate, error = "ללא"}}));
end
end


function translateEdition(str)
if str=='1st' then
return 'ראשונה'
elseif str=='2nd' then
return 'שנייה'
end
return str
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation
This is the main function doing the majority of the citation
שורה 1,590: שורה 1,637:
local TitleNote = A['TitleNote'];
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
local TitleLink = A['TitleLink'];
local Chapter = A['Chapter'];
local Chapter = autoDir(A['Chapter']);
local ChapterLink = A['ChapterLink']; -- deprecated
local ChapterLink = A['ChapterLink']; -- deprecated
local TransChapter = A['TransChapter'];
local TransChapter = A['TransChapter'];
שורה 1,613: שורה 1,660:
local At = A['At'];
local At = A['At'];


local Edition = A['Edition'];
local Edition = translateEdition(A['Edition']);
local PublicationPlace = A['PublicationPlace']
local PublicationPlace = autoDir(A['PublicationPlace'])
local Place = A['Place'];
local Place = autoDir(A['Place']);
local PublisherName = A['PublisherName'];
local PublisherName = autoDir(A['PublisherName']);
local RegistrationRequired = A['RegistrationRequired'];
local RegistrationRequired = A['RegistrationRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
שורה 1,652: שורה 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,665: שורה 1,714:
local COinS_date; -- used in the COinS metadata
local COinS_date; -- used in the COinS metadata


local IsValidDate, LocalDate
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
שורה 1,855: שורה 1,906:
end
end
else
else
DateFormat = 'Y'
Date = Year; -- promote Year to Date
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if is_set(Date) then
if is_set(Date) then
if is_set(Month) then
if is_set(Month) then
DateFormat = 'M Y'
Date = Month .. " " .. Date;
Date = Month .. " " .. Date;
end
end
שורה 2,104: שורה 2,157:
if is_set(TransTitle) then
if is_set(TransTitle) then
if is_set(Title) then
if is_set(Title) then
TransTitle = ' <span class="mw-content-rtl">' .. TransTitle .. "</span>&lrm;";
TransTitle = ' <span class="mw-content-rtl">' .. TransTitle .. "</span>";
else
else
TransError = " " .. seterror( 'trans_missing_title' );
TransError = " " .. seterror( 'trans_missing_title' );
שורה 2,167: שורה 2,220:
Pages = ": " .. Pages;
Pages = ": " .. Pages;
elseif tonumber(Pages) ~= nil then
elseif tonumber(Pages) ~= nil then
Pages = sepc .." " .. PPrefix .. Pages;
Pages = sepc ..'<span dir="rtl"> ' .. PPrefix .. Pages .. '</span>';
else
else
Pages = sepc .." " .. PPPrefix .. Pages;
Pages = sepc ..' <span dir="rtl">' .. PPPrefix .. Pages .. '</span>';
end
end
end
end
שורה 2,177: שורה 2,230:
Page = ": " .. Page;
Page = ": " .. Page;
else
else
Page = sepc .." " .. PPrefix .. Page;
Page = sepc ..' <span dir="rtl">' .. PPrefix .. Page ..'</span>';
end
end
end
end
שורה 2,259: שורה 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(mw.getContentLanguage().formatDate, 'j xg Y', 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
שורה 2,428: שורה 2,481:
-- local canonical format for dates
-- local canonical format for dates
if is_set(Date) then
if is_set(Date) then
IsValidDate, LocalDate = pcall(local_date, Date)
IsValidDate, LocalDate = pcall(local_date, Date, DateFormat)
if IsValidDate then
if IsValidDate then
Date =  mw.ustring.format( '<span style="direction:rtl;unicode-bidi:embed;">%s</span>', LocalDate)
Date =  mw.ustring.format( '<span style="direction:rtl;unicode-bidi:embed;">%s</span>', LocalDate)