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

אין תקציר עריכה
מ 111 גרסאות של הדף wikipedia:he:יחידה:Citation/CS1 יובאו
 
(103 גרסאות ביניים של 6 משתמשים אינן מוצגות)
שורה 1: שורה 1:
-- Copied from English Wikipedia and changed for Hebrew Wikipedia --
-- Copied from English Wikipedia and changed for Hebrew Wikipedia --


local z = {
local z = {
שורה 9: שורה 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_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


-- Whether variable is set or not
-- Whether variable is set or not
שורה 117: שורה 150:
end
end
-- if we get this far we have prefix and script
-- if we get this far we have prefix and script
name = mw.language.fetchLanguageName( lang, "en" ); -- get language name so that we can use it to categorize
name = mw.language.fetchLanguageName( lang, "he" ); -- get language name so that we can use it to categorize
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
-- is prefix one of these language codes?
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'en', 'he', 'fa', 'hy', 'ja', 'ko', 'ku', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'en', 'he', 'fa', 'hy', 'ja', 'ko', 'ku', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')'); -- categorize in language-specific categories, not translated
table.insert( z.properties_cats, 'ציטוט עם תסריט בשפה זרה ('..name..')'); -- categorize in language-specific categories
else
else
table.insert( z.properties_cats, 'ציטוט משתמש בתסריט בשפה זרה'); -- use this category as a catchall until language-specific category is available
table.insert( z.properties_cats, 'ציטוט משתמש בתסריט בשפה זרה'); -- use this category as a catchall until language-specific category is available
שורה 161: שורה 194:
]]
]]


function wrap_style (key, str)
function wrap_style (key, str, lang)
if not is_set( str ) then
if not is_set( str ) then
return "";
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
-- avoid italics for hebrew script
local isHebrew = mw.ustring.find( str, '[א-ת]' )
if (is_set(lang) and lang == 'he') or (isHebrew~=nil) then
return str
else
str = '<span dir="auto">'..safeforitalics( str )..'</span>';
end
end
end


שורה 203: שורה 242:
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
local chapter_error = '';
local chapter_error = '';
-- our code
if is_set (transchapter) then
transchapter = '<span class="mw-content-rtl">' .. transchapter .. "</span>";
end
-- our code end
if not is_set (chapter) then
if not is_set (chapter) then
chapter = ''; -- just to be safe for concatenation
chapter = ''; -- just to be safe for concatenation
שורה 333: שורה 376:
local message = substitute( error_state.message, arguments );
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..  
message = "<span dir=ltr class=registered_only>" .. message .. " ([[" .. cfg.messages['help page link'] ..  
"#" .. error_state.anchor .. "|" ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
cfg.messages['help page label'] .. "]])" .. "</span>";
z.error_ids[ error_id ] = true;
z.error_ids[ error_id ] = true;
שורה 642: שורה 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
שורה 687: שורה 730:
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
if is_set(inactive_year) then
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year ); -- not translated
table.insert( z.error_categories, "פרמטר DOI לא בתוקף משנת " .. inactive_year );
else
else
table.insert( z.error_categories, "תבנית ציטוט בה עבר תוקף ה-DOI" ); -- when inactive doesn't contain a recognizable year
table.insert( z.error_categories, "תבנית ציטוט עם בעיות בתוקף ה-DOI" ); -- when inactive doesn't contain a recognizable year
end
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"  
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"  
שורה 1,003: שורה 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,034: שורה 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
if str == '' then
if str == '' then
str = value;
str = value;
שורה 1,488: שורה 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)
name = mw.language.fetchLanguageName( lang:lower(), "he" ); -- get ISO 639-1 language name if Language is a proper code
name = mw.language.fetchLanguageName( lang:lower(), "he" ); -- get ISO 639-1 language name if Language is a proper code
end
end
-- our part
if not is_set (name) then
local langs = mw.language.fetchLanguageNames( "en" )
local lang1 = lang:lower()
lang1 = lang1:sub(1, 1):upper() .. lang1:sub(2)
for k, v in pairs(langs) do
if lang1 == v
then name = mw.language.fetchLanguageName( k, "he" )
break
end
end
end
-- our part end


if is_set (name) then -- if Language specified a valid ISO639-1 code
if is_set (name) then -- if Language specified a valid ISO639-1 code
שורה 1,502: שורה 1,558:
end
end


-- our part
if name == 'ויאטנמית'
  then name = 'וייטנאמית'
  end
-- our part end
if is_set (code) then
if is_set (code) then
if 'no' == code then name = 'Norwegian' end; -- override wikimedia when code is 'no'
if 0 == namespace and 'he' ~= code then -- is this page main / article space and Hebrew not the language?
if 0 == namespace and 'he' ~= code then -- is this page main / article space and Hebrew not the language?
table.insert( z.properties_cats, 'ציטוט מקור בשפה זרה (' .. code .. ')'); -- in main space and not Hebrew: categorize, not translated: 'CS1 ' .. name .. '-language sources (' .. code .. ')'
table.insert( z.properties_cats, 'ציטוט מקור בשפה זרה (' .. name .. ')'); -- in main space and not Hebrew: categorize
end
end
else
else
שורה 1,513: שורה 1,573:
end
end


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


function autoDir(str)
if str and str ~= '' then
return '<span dir="auto">' ..str .. '</span>'
end
return str
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,544: שורה 1,625:


local Year = A['Year'];
local Year = A['Year'];
local PublicationDate = A['PublicationDate'];
local PublicationDate = restoreDate(A['PublicationDate']);
local OrigYear = A['OrigYear'];
local OrigYear = A['OrigYear'];
local Date = A['Date'];
local Date = restoreDate(A['Date']);
local LayDate = A['LayDate'];
local LayDate = restoreDate(A['LayDate']);
------------------------------------------------- Get title data
------------------------------------------------- Get title data
local Title = A['Title'];
local Title = A['Title'];
שורה 1,556: שורה 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,579: שורה 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'];
local Via = A['Via'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local AccessDate = restoreDate(A['AccessDate']);
local ArchiveDate = A['ArchiveDate'];
local ArchiveDate = restoreDate(A['ArchiveDate']);
local Agency = A['Agency'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
local DeadURL = A['DeadURL']
local Language = A['Language'];
local Language = A['Language'];
local LangCode = A['Language'];
local Format = A['Format'];
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local ChapterFormat = A['ChapterFormat'];
שורה 1,615: שורה 1,697:
local LastAuthorAmp = A['LastAuthorAmp'];
local LastAuthorAmp = A['LastAuthorAmp'];
local no_tracking_cats = A['NoTracking'];
local no_tracking_cats = A['NoTracking'];
-- our code start
local Month = A['Month'];
LangCode = mw.ustring.gsub( Language, '-.*', '' );
Language = LangCode;
-- our code end


--these are used by cite interview
--these are used by cite interview
שורה 1,627: שורה 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,751: שורה 1,840:
if is_set(Others) then
if is_set(Others) then
if is_set(TitleType) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
Others = ' ' .. TitleType .. ' עם ' .. Others;
TitleType = '';
TitleType = '';
else
else
Others = ' ' .. 'Interview with ' .. Others;
Others = ' ' .. 'ראיון עם ' .. Others;
end
end
else
else
Others = '(Interview)';
Others = '(ראיון)';
end
end
end
end
שורה 1,817: שורה 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
local Month = A['Month'];
if is_set(Month) then
if is_set(Month) then
DateFormat = 'M Y'
Date = Month .. " " .. Date;
Date = Month .. " " .. Date;
end
end
שורה 1,918: שורה 2,008:
Authors = listpeople(control, a)  
Authors = listpeople(control, a)  
end
end
-- our code start
if is_set(Month) then
table.insert( z.message_tail, { seterror('deprecated_month', {}, true) } );
end
if is_set(Coauthors) then
table.insert( z.message_tail, { seterror('deprecated_coauthors', {}, true) } );
end
if is_set(ChapterLink) then
table.insert( z.message_tail, { seterror('deprecated_chapterlink', {}, true) } );
end
-- our code end


if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
שורה 2,055: שורה 2,157:
if is_set(TransTitle) then
if is_set(TransTitle) then
if is_set(Title) then
if is_set(Title) then
TransTitle = " " .. TransTitle;
TransTitle = ' <span class="mw-content-rtl">' .. TransTitle .. "</span>";
else
else
TransError = " " .. seterror( 'trans_missing_title' );
TransError = " " .. seterror( 'trans_missing_title' );
שורה 2,061: שורה 2,163:
end
end
if is_set(Title) then
-- bidi isolation. ideally we should use here bidi-isolate once browsers supports it properly.
Title = mw.ustring.format( '<span style="unicode-bidi:embed;">%s</span>', Title)
end
Title = Title .. TransTitle;
Title = Title .. TransTitle;
שורה 2,100: שורה 2,206:
end
end
end
end
Position = " " .. TimeCaption .. " " .. Time;
Position = " " .. TimeCaption .. Time;
end
end
end
end
שורה 2,114: שורה 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,124: שורה 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,206: שורה 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, 'j xg Y') -- local canonical format for dates
if is_accesssdate_ok then
AccessDate= AccessDateParsed
end
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
שורה 2,328: שורה 2,437:
if is_set(Periodical) then
if is_set(Periodical) then
if is_set(Title) or is_set(TitleNote) then  
if is_set(Title) or is_set(TitleNote) then  
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical)  
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical, LangCode)
else  
else  
Periodical = wrap_style ('italic-title', Periodical)
Periodical = wrap_style ('italic-title', Periodical, LangCode)
end
end
end
end
שורה 2,370: שורה 2,479:
local text;
local text;
local pgtext = Position .. Page .. Pages .. At;
local pgtext = Position .. Page .. Pages .. At;
-- local canonical format for dates
if is_set(Date) then
IsValidDate, LocalDate = pcall(local_date, Date, DateFormat)
if IsValidDate then
Date =  mw.ustring.format( '<span style="direction:rtl;unicode-bidi:embed;">%s</span>', LocalDate)
end
end
if is_set(Authors) then
if is_set(Authors) then
if is_set(Coauthors) then
if is_set(Coauthors) then
שורה 2,506: שורה 2,621:
no_tracking_cats = no_tracking_cats:lower();
no_tracking_cats = no_tracking_cats:lower();
local iserror = false -- our code
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
text = text .. '[[Category:' .. v ..']]';
iserror = true -- our code
end
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
text = text .. '[[Category:' .. v ..']]';
iserror = true -- our code
end
end
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
text = text .. '[[Category:' .. v ..']]';
-- iserror = true -- our code
end
end
end
end
if iserror
then text = text .. "[[קטגוריה:שגיאות ציטוט]]" end -- our code
return text
return text
שורה 2,523: שורה 2,644:
-- This is used by templates such as {{cite book}} to create the actual citation text.
-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
function z.citation(frame)
globalframe = frame
local pframe = frame:getParent()
local pframe = frame:getParent()