Content deleted Content added
No edit summary |
No edit summary |
||
Line 23:
]=]
local function
local code = code;
local descriptions = {};
for line in mw.ustring.gmatch (element, '([^\n]+)\n') do
if
code =
elseif
table.insert (descriptions, '\"' ..
elseif mw.ustring.match (line, '^ .+') then
descriptions[#descriptions] = mw.ustring.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. mw.ustring.match (line, '^ (.+)') .. '\"';
end
end
return code
end
Line 48 ⟶ 51:
Subtag: aa
Description: Afar
]=]
function p.iana_extract_lang (frame)
local page = mw.title.getCurrentTitle(); -- get a page object for this page
local content = page:getContent(); -- get unparsed content
local
local script_table = {}; -- scripts go here
local region_table = {}; -- regions go here
local file_date; -- first line
local code;
local descriptions;
-- search for nvr links and associated hull numbers
_, _, file_date = content:find ('(File%-Date: %d%d%d%d%-%d%d%-%d%d)');
for element in mw.ustring.gmatch (content, '%%%%[^%%]+') do
if mw.ustring.find (element, 'Type: language') then
code, descriptions =
table.insert (out_table, "[\'" .. code .. "\'] = {" .. descriptions .. "}"); -- make table entries▼
if code then
▲ table.insert (
end
elseif mw.ustring.find (element, 'Type: script') then
code, descriptions = get_lang_script_region_parts (element);
if code then
table.insert (script_table, "[\'" .. code .. "\'] = {" .. descriptions .. "}"); -- make table entries
end
elseif mw.ustring.find (element, 'Type: region') then
code, descriptions = get_lang_script_region_parts (element);
if code then
table.insert (region_table, "[\'" .. code .. "\'] = {" .. descriptions .. "}"); -- make table entries
end
end
end
-- make pretty output
return "<br /><pre>
file_date .. "<br />return {<br />	" .. table.concat (script_table, ',<br />	') .. "<br />	}<br />-- " ..
file_date .. "<br />return {<br />	" .. table.concat (region_table, ',<br />	') .. "<br />	}<br />" .. "</pre>";
end
|