Module:Lang: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 172: Line 172:
]=]
]=]


local function make_error_msg (msg)
local function make_error_msg (msg, nocat)
local out = {};
local out = {};
Line 178: Line 178:
table.insert (out, msg);
table.insert (out, msg);
table.insert (out, '</span>');
table.insert (out, '</span>');
-- if (0 ~= namespace) or nocat then -- only categorize in article space
table.insert (out, '[[Category:lang and lang-xx template errors]]');
-- end

return table.concat (out);
return table.concat (out);
Line 333: Line 338:
local code, script, region, variant = get_ietf_parts (args.code);
local code, script, region, variant = get_ietf_parts (args.code);
-- if is_set (code) then
-- if lang_data.override[code] then
-- language_name = lang_data.override[code][1]
-- elseif lang_name_table.lang[code] then
-- language_name = lang_name_table.lang[code][1]; -- table entries sometimes have multiple names, always take the first one
-- end
-- end
-- if not is_set (language_name) then
if not (code and script and region and variant) then
if not (code and script and region and variant) then
table.insert (out, make_error_msg (table.concat ({'unknown language code: ', args.code or 'missing'})));
table.insert (out, make_error_msg (table.concat ({'lang: unknown language code: ', args.code or 'missing'}), args.no_cat));
if 0 ~= namespace then -- only categorize in article space
-- if 0 ~= namespace then -- only categorize in article space
table.insert (out, '[[Category:Articles containing unknown language template codes');
-- table.insert (out, '[[Category:lang and lang-xx template errors');
if is_set (args.code) then
-- if is_set (args.code) then
table.insert (out, '|' .. args.code); -- add a sort key
-- table.insert (out, '|' .. args.code); -- add a sort key
end
-- end
table.insert (out, ']]');
-- table.insert (out, ']]');
end
-- end
return table.concat (out); -- emit an error message and category
return table.concat (out); -- emit an error message and category
end
end
Line 403: Line 399:
local translit_title;
local translit_title;
-- if is_set (code) then
-- if lang_data.override[code] then
-- language_name = lang_data.override[code][1]
-- elseif lang_name_table.lang[code] then
-- language_name = lang_name_table.lang[code][1]; -- table entries sometimes have multiple names, always take the first one
-- end
-- end

-- if not is_set (language_name) then
if not (code and script and region and variant) then
if not (code and script and region and variant) then
table.insert (out, make_error_msg (table.concat ({'unknown language code: ', args.code or 'missing'})));
table.insert (out, make_error_msg (table.concat ({'lang-xx: unknown language code: ', args.code or 'missing'}), args.nocat));
if 0 ~= namespace then -- only categorize in article space
-- if 0 ~= namespace then -- only categorize in article space
table.insert (out, '[[Category:Articles containing unknown language template codes');
-- table.insert (out, '[[Category:lang and lang-xx template errors');
if is_set (args.code) then
-- if is_set (args.code) then
table.insert (out, '|' .. args.code); -- add a sort key
-- table.insert (out, '|' .. args.code); -- add a sort key
end
-- end
table.insert (out, ']]');
-- table.insert (out, ']]');
end
-- end
return table.concat (out); -- emit an error message and category
return table.concat (out); -- emit an error message and category
end
end
Line 445: Line 432:
table.insert (out, ', <small>');
table.insert (out, ', <small>');
translit_title = mw.title.makeTitle (0, 'Romanization of ' .. language_name)
translit_title = mw.title.makeTitle (0, 'Romanization of ' .. language_name)
if translit_title.exists then
if translit_title.exists and ('no' ~= args.link) then
table.insert (out, make_wikilink ('Romanization of ' .. translit_script or language_name, 'translit.'));
table.insert (out, make_wikilink ('Romanization of ' .. translit_script or language_name, 'translit.'));
else
else
Line 455: Line 442:
table.insert (out, translit);
table.insert (out, translit);
else
else
-- table.insert (out, '<span style="font-size:100%" class="error">error: invalid translit std or script</span>');
table.insert (out, make_error_msg (table.concat ({'lang-xx: invalid translit std: \'', args.std or 'missing', '\' or script: \'', args.script or 'missing', '\''}), args.nocat));
table.insert (out, make_error_msg (table.concat ({'invalid translit std: \'', args.std or 'missing', '\' or script: \'', args.script or 'missing', '\''})));
end
end
end
end
Line 462: Line 448:
if is_set (args.lit) then -- translation (not supported in {{lang}})
if is_set (args.lit) then -- translation (not supported in {{lang}})
table.insert (out, ', <small>');
table.insert (out, ', <small>');
if 'no' == args.link then
table.insert (out, make_wikilink ('Literal translation', 'lit.'));
table.insert (out, '<abbr title="literal translation">lit.</abbr>');
else
table.insert (out, make_wikilink ('Literal translation', 'lit.'));
end
table.insert (out, "&nbsp;</small>'");
table.insert (out, "&nbsp;</small>'");
table.insert (out, args.lit);
table.insert (out, args.lit);