మాడ్యూల్:Citation/CS1: కూర్పుల మధ్య తేడాలు
Content deleted Content added
post-update update; |
language; generic name; |
||
పంక్తి 1,359:
local function is_generic (item, value)
local test_val;
for _, generic_value in ipairs (cfg.special_case_translation[item]) do -- spin through the list of known generic value fragments
test_val = generic_value['en'][2] and value:lower() or value; -- when set to 'true', plaintext search using lowercase value
if test_val:find (generic_value['en'][1], 1, generic_value['en'][2]) then
return true; -- found English generic value so done
elseif generic_value['local'] then -- to keep work load down, generic_<value>['local'] should be nil except when there is a local version of the generic value
if mw.ustring.find (test_val, generic_value['local'][1], 1, generic_value['local'][2]) then -- mw.ustring() because might not be Latin script
return true; -- found local generic value so done
end
Line 1,501 ⟶ 1,507:
--[[--------------------------<
attempt to decode |language=<lang_param> and return language name and matching tag; nil else.
This function looks for:
<lang_param> as a tag in cfg.lang_code_remap{}
<lang_param> as a name in cfg.lang_name_remap{}
<lang_param> as a name in cfg.mw_languages_by_name_t
<lang_param> as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that <lang_param> is an IETF-like tag that MediaWiki does not recognize. Strip all
script, region, variant, whatever subtags from <lang_param> to leave just a two or three character language tag
and look for the new <lang_param> in cfg.mw_languages_by_tag_t{}
on success, return name and matching tag; on failure return nil
]]
local function name_tag_get (lang_param)
local lang_param_lc = mw.ustring.lower (lang_param); -- use lowercase as an index into the various tables
local name = cfg.lang_code_remap[lang_param_lc]; -- assume <lang_param_lc> is a tag; attempt to get remapped language name
if name then -- when <name>, <lang_param> is a tag for a remapped language name
return name, lang_param; -- so return <name> from remap and <lang_param>
end
if cfg.lang_name_remap[lang_param_lc] then -- not a tag, assume <lang_param_lc> is a name; attempt to get remapped language tag
return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2]; -- for this <lang_param_lc>, return a (possibly) new name and appropriate tag
end
local tag = cfg.mw_languages_by_name_t[lang_param_lc]; -- assume that <lang_param_lc> is a language name; attempt to get its matching tag
if tag then
return cfg.mw_languages_by_tag_t[tag], tag; -- <lang_param_lc> is a name so return the name from the table and <tag>
end
if name then
end
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- is tag an IETF-like tag that MediaWiki doesn't recognize? <tag> gets the language subtag; nil else
if tag then
if name then
return name, tag; -- <lang_param_lc> is an unrecognized IETF-like tag so return <name> and language subtag
end
end
end
Line 1,583 ⟶ 1,582:
local function language_parameter (lang)
local
local lang_subtag; -- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
local name; -- the language name
local language_list = {}; -- table of language names to be rendered
local
local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code); -- get this wiki's language name
for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag
if utilities.is_set (tag) then
lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1'); -- for categorization, strip any IETF-like tags from language tag
if cfg.this_wiki_code ~=
if 2 ==
utilities.add_prop_cat ('foreign-lang-source', {name,
else -- or is a recognized language (but has a three-character
utilities.add_prop_cat ('foreign-lang-source-2', {
end
elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled
utilities.add_prop_cat ('local-lang-source', {name,
end
else
name = lang; -- return whatever <lang> has so that we show something
utilities.set_message ('maint_unknown_lang'); -- add maint category if not already added
end
Line 1,628 ⟶ 1,617:
name = utilities.make_sep_list (#language_list, language_list);
if (1 == #language_list) and (
return ''; -- if one language and that language is this wiki's return an empty string (no annotation)
end
|