మాడ్యూల్:Lang: కూర్పుల మధ్య తేడాలు

453 బైట్లను తీసేసారు ,  1 సంవత్సరం క్రితం
sync from sandbox;
చి (en:Module:Lang నుండి కూర్పును దిగుమతి చేసాం: తాజా)
(sync from sandbox;)
 
require('Module:No globals');
 
local initial_style_state; -- set by lang_xx_normal() and lang_xx_italic()
 
local getArgs = require ('Module:Arguments').getArgs;
local yesno = require ('Module:Yesno');
 
local lang_name_tablelang_data = mw.loadData ('Module:Language/nameLang/data/sandbox'); -- language name override and transliteration tool-tip tables
local lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts
local lang_table = lang_data.lang_name_table.lang;
local script_table = lang_data.lang_name_table.script;
local region_table = lang_data.lang_name_table.region;
local variant_table = lang_data.lang_name_table.variant;
local suppressed_table = lang_data.lang_name_table.suppressed;
local override_table = lang_data.override;
 
local synonym_table = mw.loadData ('Module:Lang/ISO 639 synonyms'); -- ISO 639-2/639-2T code translation to 639-1 code
 
local lang_data = mw.loadData ('Module:Lang/data'); -- language name override and transliteration tool-tip tables
 
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
 
local this_wiki_lang = mw.language.getContentLanguage().code; -- get this wiki's language
 
local initial_style_state; -- set by lang_xx_normal() and lang_xx_italic()
 
local maint_cats = {}; -- maintenance categories go here
script subtag - four character IANA script code
region subtag - two-letter or three digit IANA region code
variant subtag - four digit or 5-8 alnum variant code; only one variant subtag supported
private subtag - x- followed by 1-8 alnum private code; only supported with the primary language tag
 
code = code:lower(); -- ensure that we use and return lower case version of this
if not (lang_data.overrideoverride_table[code] or lang_name_table.langlang_table[code] or synonym_table[code]) then
return nil, nil, nil, nil, nil, table.concat ({'unrecognized language code: ', code}); -- invalid language code, don't know about the others (don't care?)
end
if is_set (script) then
script = script:lower(); -- ensure that we use and return lower case version of this
if not lang_name_table.scriptscript_table[script] then
return code, nil, nil, nil, nil, table.concat ({'unrecognized script: ', script, ' for code: ', code}); -- language code ok, invalid script, don't know about the others (don't care?)
end
end
if lang_name_table.suppressedsuppressed_table[script] then -- ensure that code-script does not use a suppressed script
if in_array (code, lang_name_table.suppressedsuppressed_table[script]) then
return code, nil, nil, nil, nil, table.concat ({'script: ', script, ' not supported for code: ', code}); -- language code ok, script is suppressed for this code
end
if is_set (region) then
region = region:lower(); -- ensure that we use and return lower case version of this
if not lang_name_table.regionregion_table[region] then
return code, script, nil, nil, nil, table.concat ({'unrecognized region: ', region, ' for code: ', code});
end
if is_set (variant) then
variant = variant:lower(); -- ensure that we use and return lower case version of this
if not lang_name_table.variantvariant_table[variant] then -- make sure variant is valid
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant});
end -- does this duplicate/replace tests in lang() and lang_xx()?
if is_set (script) then -- if script set it must be part of the 'prefix'
if not in_array (table.concat ({code, '-', script}), lang_name_table.variantvariant_table[variant]['prefixes']) then
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code-script pair: ', code, '-', script});
end
elseif is_set (region) then -- if region set, there are some prefixes that require lang code and region (en-CA-newfound)
if not in_array (code, lang_name_table.variantvariant_table[variant]['prefixes']) then -- first see if lang code is all that's required (en-oxendict though en-GB-oxendict is preferred)
if not in_array (table.concat ({code, '-', region}), lang_name_table.variantvariant_table[variant]['prefixes']) then -- now try for lang code and region (en-CA-newfound)
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code-region pair: ', code, '-', region});
end
end
else
if not in_array (code, lang_name_table.variantvariant_table[variant]['prefixes']) then
return code, script, region, nil, nil, table.concat ({'unrecognized variant: ', variant, ' for code: ', code});
end
if is_set (private) then
private = private:lower(); -- ensure that we use and return lower case version of this
if not lang_data.overrideoverride_table[table.concat ({code, '-x-', private})] then -- make sure private tag is valid; note that index
return code, script, region, nil, nil, table.concat ({'unrecognized private tag: ', private});
end
 
if language_name:find ('languages') then
retval =return table.concat ({'[[Category:Articles with text from the ', language_name, ' collective]]'});
-- retval =return table.concat ({'[[Category:Articles with text from ', language_name, ']]'}); -- proposed version at Wikipedia:Categories_for_discussion/Log/2020_August_18#Category:Articles_with_text_from_the_Afro-Asiatic_languages_collective
retval = name_get and retval:gsub ('[%[%]]', '') or retval; -- when called from category_from_tag() strip wikilink markup to return plain-text category name
return retval;
end
 
if 'en' == code then
table.insert (cat, 'explicitly cited English' .. language_name); -- falls back to English if regional name not available
else
table.insert (cat, language_name);
table.insert (cat, '-language text]]');
 
retval =return table.concat (cat);
retval = name_get and retval:gsub ('[%[%]]', '') or retval; -- when called from category_from_tag() strip wikilink markup to return plain-text category name
return retval
end
 
if title_table[std] then -- and if standard is legitimate
if title_table[std][tscript] then -- and if script for that standard is legitimate
table.insert (tout, table.concat ({title_table[std][tscript:lower()], ' (', lang_name_table.scriptscript_table[tscript][1], ' script) transliteration'})); -- add the appropriate text to the tool tip
else
table.insert (tout, title_table[std]['default']); -- use the default if script not in std table; TODO: maint cat? error message because script not found for this standard?
if title_table[std][code] then -- if language code is in the table (transl may not provide a language code)
table.insert (tout, table.concat ({title_table[std][code:lower()], ' (', lang_name_table.langlang_table[code][1], ' language) transliteration'})); -- add the appropriate text to the tool tip
else -- code doesn't match
table.insert (tout, title_table[std]['default']); -- so use the standard's default
 
local function language_name_get (ietf, code, variant)
ifietf = lang_data.override[ietf:lower()] then; -- lookietf:lower() forbecause whole IETF tagformat_ietf_tag() inreturns overridemixed tablecase
if override_table[ietf] then -- look for whole IETF tag in override table
return lang_data.override[ietf:lower()][1]; -- ietf:lower() because format_ietf_tag() returns mixed case
return override_table[ietf][1];
elseif lang_data.overrideoverride_table[code] then -- not there so try basic language code
return lang_data.overrideoverride_table[code][1];
elseif not is_set (variant)lang_table[code] then -- shift to mainiana code/name tablestable
if lang_name_table.lang[code] then
return lang_name_table.langlang_table[code][1]; -- table entries sometimes have multiple names, always take the first one
end
else -- TODO: is this the right thing to do: take language display name from variants table?
if lang_name_table.variant[variant] then -- TODO: there is some discussion at Template talk:Lang about having a label parameter for use when variant name is not desired among other things
return lang_name_table.variant[variant]['descriptions'][1]; -- table entries sometimes have multiple names, always take the first one
end
end
end
 
 
--[[--------------------------< _ L A N G >--------------------------------------------------------------------
end
msg = validate_text (template, args); -- ensure that |text= is set
if is_set (msg) then -- msg is an already-formatted error message
return msg;
if 'none' ~= args.label then
table.insert (out, '<small>');
if lang_name_table.scriptscript_table[args['translit-script']] then -- when |translit-script= is set, try to use the script's name
translit_script_name = lang_name_table.scriptscript_table[args['translit-script'][1]];
else
translit_script_name = language_name; -- fall back on language name
 
if args[1] and '' ~= args[1] then
local data = mw.loadData ('Module:Lang/name to tag/sandbox'); -- get the reversed data tables TODO: change when going live
local lang = args[1]:lower(); -- allow any-case for the language name (speeling must till be correct)
local tag = data.rev_lang_datarev_override_table[lang] or data.rev_lang_name_tablerev_lang_table[lang]; -- get the code; look first in the override then in the standard
 
if tag then
end
else
return make_error_msg ('missing language / script code', args, 'transl'); -- missing language / script code so quit
end
 
end
 
if lang_data.overrideoverride_table[args.code] then -- is code a language code defined in the override table?
language_name = lang_data.overrideoverride_table[args.code][1];
elseif lang_name_table.langlang_table[args.code] then -- is code a language code defined in the standard language code tables?
language_name = lang_name_table.langlang_table[args.code][1];
elseif lang_name_table.scriptscript_table[args.code] then -- if here, code is not a language code; is it a script code?
language_name = lang_name_table.scriptscript_table[args.code][1];
script = args.code; -- code was an ISO 15924 script so use that instead
args.code = ''; -- unset because not a language code
local code; -- the language code
local msg; -- gets an error message if IETF language tag is malformed or invalid
local language_namecategory_name = '';
code, subtags.script, subtags.region, subtags.variant, subtags.private, msg = get_ietf_parts (raw_code);
 
raw_code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant, subtags.private); -- format to recommended subtag styles; private omitted because private
language_namecategory_name = language_name_get (raw_code, code, subtags.variant); -- get language name; try ietf tag first, then code w/o variant then code w/ variant
returncategory_name = make_category (code, language_namecategory_name, nil, true):gsub ('[%[%]]', '');
 
return category_name;
return make_category (code, language_name, nil, true)
end
 
అజ్ఞాత వాడుకరి
"https://te.wikipedia.org/wiki/ప్రత్యేక:MobileDiff/3052263" నుండి వెలికితీశారు