Module:Citation/CS1: Difference between revisions
From Podpedia
Content added Content deleted
(synch from sandbox;) |
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') |
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) |
||
local remap = { |
|||
if 'bangla' == lang:lower() then -- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR |
|||
['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 |
||
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 |
||
|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. |
||
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 |
|||
⚫ | |||
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); |