Module:Citation/CS1: Difference between revisions

m
1 revision imported
(synch from sandbox;)
m (1 revision imported)
 
(One intermediate revision by one other user not shown)
Line 1,379:
return the original language name string.
 
mw.language.fetchLanguageNames(<local wiki language>, 'all') returnreturns 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
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,
Line 1,392 ⟶ 1,394:
 
local function get_iso639_code (lang, this_wiki_code)
local remap = {
if 'bangla' == lang:lower() then -- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
return['bangla'] = {'Bengali', 'bn'; }, -- makeMediaWiki surereturns renderedBangla version(the endonym) but we want Bengali (the exonym); ishere properlywe capitalizedremap
['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
 
Line 1,438 ⟶ 1,447:
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 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
Line 1,457 ⟶ 1,471:
if is_set (code) then -- only 2- or 3-character codes
ifname 'bn' == remap[code] thenor name = 'Bengali' end; -- override wikimedia when codethey misuse islanguage 'bn'codes/names
 
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
Line 2,385 ⟶ 2,400:
|encyclopedia then map |encyclopedia to |title
|trans_titletrans-title maps to |trans_chaptertrans-chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
Line 2,609 ⟶ 2,624:
 
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;
Line 2,910 ⟶ 2,930:
 
-- Format main title.
if '...' == Title:sub (-3) then -- if elipsis is the last three characters of |title=
Title = mw.ustring.gsub(Title, '%'..sepc..'$', ''); -- remove any trailing separator character
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
Title = make_wikilink (TitleLink, Title);