Module:Lang: Difference between revisions

Content deleted Content added
No edit summary
m 1 revision imported
 
(2 intermediate revisions by 2 users not shown)
Line 706:
local close_tag;
if is_set (code) then -- when a language code is provided (always with {{lang-xx}} templates, not always with {{transl}})
code = code:match ('^(%a%a%a?)'); -- strip all subtags leaving only the language subtag
 
if not style then -- nil for the default italic style
table.insert (out_t, "<i lang=\""); -- so use <i> tag
Line 1,536 ⟶ 1,538:
args.text = args[2]; -- get the transliterated text
else
if args[1] and (args[1]:match ('^%a%a%a?%a?$') thenor -- args[2] missing; is args[1] a codelanguage or script tag or is it the transliterated text?
return make_error_msgargs[1]:match ('no text', args, 'Transl^%a%a%a?%-x%-');) then -- or is args[1] is a code so we're missingprivate-use texttag
return make_error_msg ('no text', args, 'Transl'); -- args[1] is a code so we're missing text
else
args.text = args[1]; -- args[1] is not a code so we're missing that; assign args.text for error message
Line 1,546 ⟶ 1,549:
 
if is_set (args[1]) then -- IANA language code used for html lang= attribute; or ISO 15924 script code
if args[1]:match ('^%a%a%a?%a?$') or args[1]:match ('^%a%a%a?%-x%-') then -- args[1] has correct form?
args.code = args[1]:lower(); -- use the language/script code; only (2, 3, or 4 alpha characters) or private-use; lower case because table indexes are lower case
else
return make_error_msg (table.concat ({'unrecognized language / script code: ', args[1]}), args, 'Transl'); -- invalid language / script code
Line 1,566 ⟶ 1,569:
if override_table[args.code] then -- is code a language code defined in the override table?
language_name = override_table[args.code];
args.code = args.code:match ('^%a%a%a?'); -- if private use, strip all but language subtag
elseif lang_table[args.code] then -- is code a language code defined in the standard language code tables?
language_name = lang_table[args.code];