Anonymous user
Module:Lang: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 437:
function p.lang (frame)
local args = getArgs(frame);
if args[1] and args.code then
return make_error_msg ('{{lang}}: conflicting: {{{1}}} and |code=', args.nocat);
else
args.code = args[1] or args.code;
end
if args[2] and args.text then
return make_error_msg ('{{lang}}: conflicting: {{{2}}} and |text=', args.nocat);
else
args.text = args[2] or args.text;
end
local out = {};
local language_name;
local subtags = {};
local code, script, region, variant = get_ietf_parts (args.code or args[1]);▼
local code;
▲
if not (code and subtags.script and subtags.region and subtags.variant) then
return make_error_msg (table.concat ({'{{lang}}: unknown language code: ', args.code
end
if
if not in_array (code, lang_name_table.variant[subtags.variant]['prefixes']) then
args.italic = 'no'; -- DEFAULT for {{lang}} templates is to not italicize▼
return make_error_msg (table.concat ({'{{lang}}: invalid code-variant combination: ', code, '-', subtags.variant}), args.nocat);
end
end
if not is_set (args.italic) then -- args.italic controls
if 'latn' == subtags.script then -- script set to latn
▲ args.italic = '
else
args.italic = 'no'; -- italic not set; script not latn
end
end
args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant);
if lang_data.override[code] then
Line 515 ⟶ 535:
args.text = args[1] or args.text;
end
if args[2] and args.translit then
return make_error_msg ('{{lang-xx}}: conflicting: {{{2}}} and |translit=', args.nocat);
|