Module:Lang/utilities: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 6:
 
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
 
local err_texts = { -- because wrapper templates have Latn/non-Latn text ordered according to the wrapper template's name
['lang-sh-cyrl-latn'] = true, -- this template has |1=cyrl script |2=latn script
}
 
 
Line 14 ⟶ 18:
]]
 
local function error_msg_make (msg, template, args_tnocat)
local out = {};
local category = 'Lang and lang-xx';
 
table.insert (out, table.concat ({'<span style=\"color:#d33\">Error: <span style="font-family: monospace, monospace;">{{', template, '}}</span>: '}));
table.insert (out, msg);
table.insert (out, table.concat ({' ([[Template:Lang-x2', template, '#Error messages|help]])'}));
table.insert (out, '</span>');
Line 153 ⟶ 157:
 
if not (tag and text1 and text2) then
return error_msg_make ('missing a required argument', template_name, args_tnocat);
end
if tag:find ('-', 1, true) then
return error_msg_make ('invalid language tag: <codespan style="colorfont-family: inherit; background: inherit; border: none; padding:monospace, inheritmonospace;">' .. tag .. '</codespan>; IETF format not supported', template_name, args_tnocat);
end
iflocal notis_latn, pos = unicode.is_Latin (text1) then;
if not is_latn then
return error_msg_make ('<code style="color: inherit; background: inherit; border: none; padding: inherit;">&lt;text1></code> is not Latin script', template_name, args_t);
return error_msg_make ('<span style="font-family: monospace, monospace;">&lt;' .. ((err_texts[template_name:lower()] and 'text2') or 'text1') .. '></span> is not Latin script (pos ' .. pos .. ')', template_name, nocat);
end
ifis_latn, pos = unicode.is_Latin (text2) then;
if is_latn then
return error_msg_make ('<code style="color: inherit; background: inherit; border: none; padding: inherit;">&lt;text2></code> is Latin script', template_name, args_t);
return error_msg_make ('<span style="font-family: monospace, monospace;">&lt;' .. ((err_texts[template_name:lower()] and 'text1') or 'text2') .. '></span> is Latin script (pos ' .. pos .. ')', template_name, nocat);
end