Module:Lang/data/iana languages/make: Difference between revisions

Content deleted Content added
No edit summary
m find function may be faster in if-statements
Line 41:
local in_comments = false;
 
if mw.ustring.matchfind (record, 'Deprecated') or mw.ustring.find (record, 'Preferred%-Value') or mw.ustring.find (record, 'Private use') then
return 'skip';
end
 
for line in mw.ustring.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
if mw.ustring.matchfind (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = mw.ustring.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code
elseif mw.ustring.matchfind (line, 'Description: .+') then -- if this line is a description line
local desc = mw.ustring.match (line, 'Description: (.+)'); -- extract the description
desc = mw.ustring.gsub (desc, '"', '\\"'); -- in case description contains quote marks (see 1959acad)
table.insert (descriptions, '\"' .. desc .. '\"'); -- save the description wrapped in quote marks
elseif mw.ustring.matchfind (line, 'Prefix: .+') then -- if this line is a prefix line
table.insert (prefixes, '\"' .. mw.ustring.match (line, 'Prefix: (.+)') .. '\"'); -- extract and save the prefix wrapped in quote marks
elseif mw.ustring.matchfind (line, 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif mw.ustring.matchfind (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
descriptions[#descriptions] = mw.ustring.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. mw.ustring.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
Line 100:
local in_comments = false;
 
if mw.ustring.matchfind (record, 'Deprecated') or mw.ustring.find (record, 'Preferred%-Value') or mw.ustring.find (record, 'Private use') then
return 'skip';
end
 
for line in mw.ustring.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
if mw.ustring.matchfind (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = mw.ustring.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code
elseif mw.ustring.matchfind (line, 'Description: .+') then -- if this line is a description line
table.insert (descriptions, '\"' .. mw.ustring.match (line, 'Description: (.+)') .. '\"'); -- extract and save the name wrapped in quote marks
elseif mw.ustring.matchfind (line, 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif mw.ustring.matchfind (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
descriptions[#descriptions] = mw.ustring.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. mw.ustring.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark