コアサーバーV2プランご契約でドメイン更新費用が永久無料
コンテンツにスキップ

“モジュール:Lang” のwerson間の差分

50 バイト除去 、 2024 ppm 3 2024-03-05T15:13:14+00:00up 5 312024 (Ape.)
編集の要約なし
(Cinaitak uk)
編集の要約なし
324行目: 324行目:


if not code then
if not code then
return nil, nil, nil, nil, nil, table.concat ({'无法识别的语言标签:', source}); -- don't know what we got but it is malformed
return nil, nil, nil, nil, nil, table.concat ({'无法识别的语言标签: ', source}); -- don't know what we got but it is malformed
end
end


330行目: 330行目:
if not (override_table[code] or lang_table[code] or synonym_table[code] or lang_dep_table[code]) then
if not (override_table[code] or lang_table[code] or synonym_table[code] or lang_dep_table[code]) then
return nil, nil, nil, nil, nil, table.concat ({'无法识别的语言代码:', code}); -- invalid language code, don't know about the others (don't care?)
return nil, nil, nil, nil, nil, table.concat ({'无法识别的语言代码: ', code}); -- invalid language code, don't know about the others (don't care?)
end
end
if synonym_table[code] then -- if 639-2/639-2T code has a 639-1 synonym
if synonym_table[code] then -- if 639-2/639-2T code has a 639-1 synonym
table.insert (maint_cats, table.concat ({'Lang和lang-xx代码升级为ISO 639-1|', code}));
table.insert (maint_cats, table.concat ({'Lang和lang-xx代码升级为ISO 639-1|', code}));
table.insert (maint_msgs, table.concat ({'代码:', code, '升级为代码:', synonym_table[code]}));
table.insert (maint_msgs, table.concat ({'代码: ', code, '升级为代码: ', synonym_table[code]}));
code = synonym_table[code]; -- use the synonym
code = synonym_table[code]; -- use the synonym
end
end
350行目: 350行目:
script = script:lower(); -- ensure that we use and return lower case version of this
script = script:lower(); -- ensure that we use and return lower case version of this
if not script_table[script] then
if not script_table[script] then
return code, nil, nil, nil, nil, table.concat ({'无法识别的文本:', script, '用于代码:', code}); -- language code ok, invalid script, don't know about the others (don't care?)
return code, nil, nil, nil, nil, table.concat ({'无法识别的文本: ', script, '用于代码: ', code}); -- language code ok, invalid script, don't know about the others (don't care?)
end
end
end
end
if suppressed_table[script] then -- ensure that code-script does not use a suppressed script
if suppressed_table[script] then -- ensure that code-script does not use a suppressed script
if in_array (code, suppressed_table[script]) then
if in_array (code, suppressed_table[script]) then
return code, nil, nil, nil, nil, table.concat ({'文本:', script, '不支持代码:', code}); -- language code ok, script is suppressed for this code
return code, nil, nil, nil, nil, table.concat ({'文本: ', script, '不支持代码: ', code}); -- language code ok, script is suppressed for this code
end
end
end
end
370行目: 370行目:
region = region:lower(); -- ensure that we use and return lower case version of this
region = region:lower(); -- ensure that we use and return lower case version of this
if not region_table[region] then
if not region_table[region] then
return code, script, nil, nil, nil, table.concat ({'无法识别的地区:', region, '用于代码:', code});
return code, script, nil, nil, nil, table.concat ({'无法识别的地区: ', region, '用于代码: ', code});
end
end
end
end
385行目: 385行目:
variant = variant:lower(); -- ensure that we use and return lower case version of this
variant = variant:lower(); -- ensure that we use and return lower case version of this
if not variant_table[variant] then -- make sure variant is valid
if not variant_table[variant] then -- make sure variant is valid
return code, script, region, nil, nil, table.concat ({'无法识别的变体:', variant});
return code, script, region, nil, nil, table.concat ({'无法识别的变体: ', variant});
end -- does this duplicate/replace tests in lang() and lang_xx()?
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 is_set (script) then -- if script set it must be part of the 'prefix'
if not in_array (table.concat ({code, '-', script}), variant_table[variant]['prefixes']) then
if not in_array (table.concat ({code, '-', script}), variant_table[variant]['prefixes']) then
return code, script, region, nil, nil, table.concat ({'无法识别的变体:', variant, '用于代码-文本对:', code, '-', script});
return code, script, region, nil, nil, table.concat ({'无法识别的变体: ', variant, '用于代码-文本对: ', code, '-', script});
end
end
elseif is_set (region) then -- if region set, there are some prefixes that require lang code and region (en-CA-newfound)
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, variant_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 (code, variant_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}), variant_table[variant]['prefixes']) then -- now try for lang code and region (en-CA-newfound)
if not in_array (table.concat ({code, '-', region}), variant_table[variant]['prefixes']) then -- now try for lang code and region (en-CA-newfound)
return code, script, region, nil, nil, table.concat ({'无法识别的变体:', variant, '用于代码-文本对:', code, '-', region});
return code, script, region, nil, nil, table.concat ({'无法识别的变体: ', variant, '用于代码-文本对: ', code, '-', region});
end
end
end
end
else
else
if not in_array (code, variant_table[variant]['prefixes']) then
if not in_array (code, variant_table[variant]['prefixes']) then
return code, script, region, nil, nil, table.concat ({'无法识别的变体:', variant, '用于代码:', code});
return code, script, region, nil, nil, table.concat ({'无法识别的变体: ', variant, '用于代码: ', code});
end
end
end
end
407行目: 407行目:
private = private:lower(); -- ensure that we use and return lower case version of this
private = private:lower(); -- ensure that we use and return lower case version of this
if not override_table[table.concat ({code, '-x-', private})] then -- make sure private tag is valid; note that index  
if not override_table[table.concat ({code, '-x-', private})] then -- make sure private tag is valid; note that index  
return code, script, region, nil, nil, table.concat ({'无法识别的私有标签:', private});
return code, script, region, nil, nil, table.concat ({'无法识别的私有标签: ', private});
end
end
end
end
431行目: 431行目:
table.insert (out, table.concat ({'[', args.text or '未定义', '] '})); -- for error messages output args.text if available
table.insert (out, table.concat ({'[', args.text or '未定义', '] '})); -- for error messages output args.text if available
table.insert (out, table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误:{{', template, '}}'}));
table.insert (out, table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误: {{', template, '}}: '}));
table.insert (out, msg);
table.insert (out, msg);
table.insert (out, table.concat ({'([[:Category:', category, '模板错误|帮助]])'}));
table.insert (out, table.concat ({'([[:Category:', category, '模板错误|帮助]])'}));
566行目: 566行目:
--[=[-------------------------< M A K E _ C A T E G O R Y >----------------------------------------------------
--[=[-------------------------< M A K E _ C A T E G O R Y >----------------------------------------------------


注意:此处有修改
注意: 此处有修改


对于中文,则返回以下分类:
对于中文,则返回以下分类:
[[Category:含有明确引用中文的条目]]
[[Category:含有明确引用中文的条目]]


对于非中文内容:
对于非中文内容:


如果是常用语言,则直接返回以下分类:
如果是常用语言,则直接返回以下分类:
[[Category:含有<语言>的条目]](此处的<语言>为本模块内建)
[[Category:含有<语言>的条目]](此处的<语言>为本模块内建)


如果是非常用语言:
如果是非常用语言:


如果存在对应语言的分类,则返回以下分类:
如果存在对应语言的分类,则返回以下分类:
[[Category:含有<语言>的条目]](此处的<语言>需读取数据库资料)
[[Category:含有<语言>的条目]](此处的<语言>需读取数据库资料)


反之,则返回以下分类:
反之,则返回以下分类:
[[Category:含有非中文内容的条目]]
[[Category:含有非中文内容的条目]]


882行目: 882行目:
if lang_dep_table[code] and cat then -- because deprecated code may have been overridden to en.wiki preferred name
if lang_dep_table[code] and cat then -- because deprecated code may have been overridden to en.wiki preferred name
table.insert (maint_cats, table.concat ({'Lang和lang-xx使用弃用的ISO 639代码|', code}));
table.insert (maint_cats, table.concat ({'Lang和lang-xx使用弃用的ISO 639代码|', code}));
table.insert (maint_msgs, table.concat ({'代码:', code, '已弃用'}));
table.insert (maint_msgs, table.concat ({'代码: ', code, '已弃用'}));
end
end


913行目: 913行目:


if args[1] and args.code then
if args[1] and args.code then
return make_error_msg ('冲突:{{{1}}} 和 |code=', args, template);
return make_error_msg ('冲突: {{{1}}} 和 |code=', args, template);
else
else
args.code = args[1] or args.code; -- prefer args.code
args.code = args[1] or args.code; -- prefer args.code
919行目: 919行目:


if args[2] and args.text then
if args[2] and args.text then
return make_error_msg ('冲突:{{{2}}} 和 |text=', args, template);
return make_error_msg ('冲突: {{{2}}} 和 |text=', args, template);
else
else
args.text = args[2] or args.text; -- prefer args.text
args.text = args[2] or args.text; -- prefer args.text
935行目: 935行目:
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
if msg then
return make_error_msg (table.concat ({'无效|proto=', args.proto}), args, template);
return make_error_msg (table.concat ({'无效|proto=: ', args.proto}), args, template);
end
end


973行目: 973行目:
end
end
-- 中文版特化部分:为非中文文字禁用繁简转换,中文文字和其他以汉字作为书写系统的汉语方言文字启用繁简转换。
-- 中文版特化部分: 为非中文文字禁用繁简转换,中文文字和其他以汉字作为书写系统的汉语方言文字启用繁简转换。
if 'zh' == code then
if 'zh' == code then
args.text = args.text
args.text = args.text
1,089行目: 1,089行目:


if args[1] and args.text then
if args[1] and args.text then
return make_error_msg ('冲突:{{{1}}} 和 |text=', args, template);
return make_error_msg ('冲突: {{{1}}} 和 |text=', args, template);
else
else
args.text = args[1] or args.text; -- prefer args.text
args.text = args[1] or args.text; -- prefer args.text
1,102行目: 1,102行目:


if args[2] and args.translit then
if args[2] and args.translit then
return make_error_msg ('冲突:{{{2}}} 和 |translit=', args, template);
return make_error_msg ('冲突: {{{2}}} 和 |translit=', args, template);
else
else
args.translit = args[2] or args.translit -- prefer args.translit
args.translit = args[2] or args.translit -- prefer args.translit
1,108行目: 1,108行目:
if args[3] and (args.translation or args.lit) then
if args[3] and (args.translation or args.lit) then
return make_error_msg ('冲突:{{{3}}} 和 |lit= or |translation=', args, template);
return make_error_msg ('冲突: {{{3}}} 和 |lit= or |translation=', args, template);
elseif args.translation and args.lit then
elseif args.translation and args.lit then
return make_error_msg ('冲突:|lit= 和 |translation=', args, template);
return make_error_msg ('冲突: |lit= 和 |translation=', args, template);
else
else
args.translation = args[3] or args.translation or args.lit; -- prefer args.translation
args.translation = args[3] or args.translation or args.lit; -- prefer args.translation
1,116行目: 1,116行目:


if args.links and args.link and (args.links ~= args.link) then
if args.links and args.link and (args.links ~= args.link) then
return make_error_msg ('冲突:|links= 和 |link=', args, template);
return make_error_msg ('冲突: |links= 和 |link=', args, template);
else
else
args.link = args.link or args.links; -- prefer args.link
args.link = args.link or args.links; -- prefer args.link
1,158行目: 1,158行目:
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
args.proto, msg = validate_proto (args.proto); -- return boolean, or nil, or nil and error message flag
if msg then
if msg then
return make_error_msg (table.concat ({'无效 |proto=', args.proto}), args, template);
return make_error_msg (table.concat ({'无效 |proto=: ', args.proto}), args, template);
end
end


1,169行目: 1,169行目:
if args.label then
if args.label then
if 'none' ~= args.label then
if 'none' ~= args.label then
table.insert (out, table.concat ({args.label, ''})); -- custom label
table.insert (out, table.concat ({args.label, ': '})); -- custom label
end
end
else
else
1,181行目: 1,181行目:
end
end
end
end
table.insert (out, ''); -- separator
table.insert (out, ': '); -- separator
end
end


1,188行目: 1,188行目:
end
end
-- 中文版特化部分:为非中文文字禁用繁简转换,中文文字和其他以汉字作为书写系统的汉语方言文字启用繁简转换。
-- 中文版特化部分: 为非中文文字禁用繁简转换,中文文字和其他以汉字作为书写系统的汉语方言文字启用繁简转换。
if 'zh' == code then
if 'zh' == code then
args.text = args.text
args.text = args.text
1,224行目: 1,224行目:
table.insert (out, '羅馬化'); -- else plain text
table.insert (out, '羅馬化'); -- else plain text
end
end
table.insert (out, '</small>'); -- close the small tag
table.insert (out, ': </small>'); -- close the small tag
end
end
1,244行目: 1,244行目:
table.insert (out, make_wikilink ('直译'));
table.insert (out, make_wikilink ('直译'));
end
end
table.insert (out, "</small>");
table.insert (out, ": </small>");
end
end
table.insert (out, table.concat ({args.translation})); -- use html entities to avoid wiki markup confusion
table.insert (out, table.concat ({args.translation})); -- use html entities to avoid wiki markup confusion
1,403行目: 1,403行目:
if msg then
if msg then
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误:', template, msg, '</span>'});
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误: ', template, msg, '</span>'});
end
end


1,455行目: 1,455行目:
return tag, true; -- language name found so return tag and done; second return used by is_lang_name()
return tag, true; -- language name found so return tag and done; second return used by is_lang_name()
else
else
msg = '语言:' .. args[1] .. '未找到' -- language name not found, error message
msg = '语言: ' .. args[1] .. '未找到' -- language name not found, error message
end
end
else
else
1,465行目: 1,465行目:
template = table.concat ({'{{', args['template'], '}}: '}); -- make template name (if provided by the template)
template = table.concat ({'{{', args['template'], '}}: '}); -- make template name (if provided by the template)
end
end
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误:', template, msg, '</span>'});
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误: ', template, msg, '</span>'});
end
end


1,511行目: 1,511行目:


if not title_table[args.translit_std] then
if not title_table[args.translit_std] then
return make_error_msg (table.concat ({'无法识别的转译标准:', args.translit_std}), args, 'Transl');
return make_error_msg (table.concat ({'无法识别的转译标准: ', args.translit_std}), args, 'Transl');
end
end
else
else
1,530行目: 1,530行目:
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters); lower case because table indexes are lower case
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters); lower case because table indexes are lower case
else
else
return make_error_msg (table.concat ({'无法识别的语言/文字代码:', args[1]}), args, 'Transl'); -- invalid language / script code
return make_error_msg (table.concat ({'无法识别的语言/文字代码: ', args[1]}), args, 'Transl'); -- invalid language / script code
end
end
else
else
1,556行目: 1,556行目:
args.code = ''; -- unset because not a language code
args.code = ''; -- unset because not a language code
else
else
return make_error_msg (table.concat ({'无法识别的语言/文字代码:', args.code}), args, 'Transl'); -- invalid language / script code
return make_error_msg (table.concat ({'无法识别的语言/文字代码: ', args.code}), args, 'Transl'); -- invalid language / script code
end
end
-- here only when all parameters passed to make_translit() are valid
-- here only when all parameters passed to make_translit() are valid
1,596行目: 1,596行目:
if msg then
if msg then
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
local template = (args['template'] and table.concat ({'{{', args['template'], '}}: '})) or ''; -- make template name (if provided by the template)
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误:', template, msg, '</span>'});
return table.concat ({'<span style=\"font-size: 100%; font-style: normal;\" class=\"error\">错误: ', template, msg, '</span>'});
end
end