Module:Citation/CS1: Difference between revisions

no edit summary
imported>Rob Kam
m (1 revision imported: Template:Reflist)
m>Trappist the monk
No edit summary
Line 1,379: Line 1,379:
return the original language name string.
return the original language name string.


mw.language.fetchLanguageNames(<local wiki language>, 'all') return a list of languages that in some cases may include
mw.language.fetchLanguageNames(<local wiki language>, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.
code 'cbk' or name 'Chavacano'. Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  These names can be found (for the time being) at
https://phabricator.wikimedia.org/diffusion/ECLD/browse/master/LocalNames/LocalNamesEn.php


Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
Line 1,392: Line 1,394:


local function get_iso639_code (lang, this_wiki_code)
local function get_iso639_code (lang, this_wiki_code)
if 'bangla' == lang:lower() then -- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
local remap = {
return 'Bengali', 'bn'; -- make sure rendered version is properly capitalized
['bangla'] = {'Bengali', 'bn'}, -- MediaWiki returns Bangla (the endonym) but we want Bengali (the exonym); here we remap
['bengali'] = {'Bengali', 'bn'}, -- MediaWiki doesn't use exonym so here we provide correct language name and 639-1 code
['bihari'] = {'Bihari', 'bh'}, -- MediaWiki replace 'Bihari' with 'Bhojpuri' so 'Bihari' cannot be found
['bhojpuri'] = {'Bhojpuri', 'bho'}, -- MediaWiki uses 'bh' as a subdomain name for Bhojpuri wWikipedia: bh.wikipedia.org
}
if remap[lang:lower()] then
return remap[lang:lower()][1], remap[lang:lower()][2]; -- for this language 'name', return a possibly new name and appropriate code
end
end


Line 1,438: Line 1,447:
local this_wiki_code = this_wiki:getCode() -- get this wiki's language code
local this_wiki_code = this_wiki:getCode() -- get this wiki's language code
local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code); -- get this wiki's language name
local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code); -- get this wiki's language name
local remap = {
['bh'] = 'Bihari', -- MediaWiki uses 'bh' as a subdomain name for Bhojpuri wWikipedia: bh.wikipedia.org
['bn'] = 'Bengali', -- MediaWiki returns Bangla
}


names_table = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list
names_table = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list
Line 1,457: Line 1,471:
if is_set (code) then -- only 2- or 3-character codes
if is_set (code) then -- only 2- or 3-character codes
if 'bn' == code then name = 'Bengali' end; -- override wikimedia when code is 'bn'
name = remap[code] or name; -- override wikimedia when they misuse language codes/names
 
if this_wiki_code ~= code then -- when the language is not the same as this wiki's language
if this_wiki_code ~= code then -- when the language is not the same as this wiki's language
if 2 == code:len() then -- and is a two-character code
if 2 == code:len() then -- and is a two-character code
Line 2,385: Line 2,400:
|encyclopedia then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|trans-title maps to |trans-chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
|url maps to |chapterurl when |title is remapped
Line 2,609: Line 2,624:


anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);
anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);
-- start temporary Julian / Gregorian calendar uncertainty categorization
if COinS_date.inter_cal_cat then
add_prop_cat ('jul_greg_uncertainty');
end
-- end temporary Julian / Gregorian calendar uncertainty categorization


if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;  
if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;  
Line 2,910: Line 2,930:


-- Format main title.
-- Format main title.
Title = mw.ustring.gsub(Title, '%'..sepc..'$', ''); -- remove any trailing separator character
if '...' == Title:sub (-3) then -- if elipsis is the last three characters of |title=
Title = mw.ustring.gsub (Title, '(%.%.%.)%.+$', '%1'); -- limit the number of dots to three
elseif not mw.ustring.find (Title, '%.%s*%a%.') then -- end of title is not a 'dot-(optional space-)letter-dot' initialism
Title = mw.ustring.gsub(Title, '%'..sepc..'$', ''); -- remove any trailing separator character
end
if is_set(TitleLink) and is_set(Title) then
if is_set(TitleLink) and is_set(Title) then
Title = make_wikilink (TitleLink, Title);
Title = make_wikilink (TitleLink, Title);
Anonymous user