Module:Lang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
No edit summary |
||
Line 437: | Line 437: | ||
function p.lang (frame) |
function p.lang (frame) |
||
local args = getArgs(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 out = {}; |
||
local language_name; |
local language_name; |
||
local subtags = {}; |
|||
⚫ | |||
local code; |
|||
⚫ | |||
if not (code and script and region and variant) then |
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 |
return make_error_msg (table.concat ({'{{lang}}: unknown language code: ', args.code or 'missing'}), args.nocat); |
||
end |
end |
||
⚫ | |||
if |
if is_set (subtags.variant) then -- special case test for |variant= |
||
if not in_array (code, lang_name_table.variant[subtags.variant]['prefixes']) then |
|||
⚫ | |||
return make_error_msg (table.concat ({'{{lang}}: invalid code-variant combination: ', code, '-', subtags.variant}), args.nocat); |
|||
end |
|||
end |
end |
||
if not is_set (args.italic) then -- args.italic controls |
|||
local msg = validate_text ('lang', args); |
|||
if 'latn' == subtags.script then -- script set to latn |
|||
if is_set (msg) then |
|||
⚫ | |||
return msg; |
|||
else |
|||
args.italic = 'no'; -- italic not set; script not latn |
|||
end |
|||
end |
end |
||
args.code = format_ietf_tag (code, script, region, variant); |
args.code = format_ietf_tag (code, subtags.script, subtags.region, subtags.variant); -- format to recommended subtag styles |
||
if lang_data.override[code] then |
if lang_data.override[code] then |
||
Line 515: | Line 535: | ||
args.text = args[1] or args.text; |
args.text = args[1] or args.text; |
||
end |
end |
||
if args[2] and args.translit then |
if args[2] and args.translit then |
||
return make_error_msg ('{{lang-xx}}: conflicting: {{{2}}} and |translit=', args.nocat); |
return make_error_msg ('{{lang-xx}}: conflicting: {{{2}}} and |translit=', args.nocat); |