local in_comments = false;
if mw.ustringstring.find (record, 'Deprecated') or mw.ustringstring.find (record, 'Preferred%-Value') or mw.ustringstring.find (record, 'Private use') then
return 'skip';
end
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
if mw.ustringstring.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = mw.ustringstring.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code
elseif mw.ustringstring.find (line, 'Description: .+') then -- if this line is a description line
local desc = mw.ustringstring.match (line, 'Description: (.+)'); -- extract the description
desc = mw.ustringstring.gsub (desc, '"', '\\"'); -- in case description contains quote marks (see 1959acad)
table.insert (descriptions, '\"' .. desc .. '\"'); -- save the description wrapped in quote marks
elseif mw.ustringstring.find (line, 'Prefix: .+') then -- if this line is a prefix line
table.insert (prefixes, '\"' .. mw.ustringstring.match (line, 'Prefix: (.+)') .. '\"'); -- extract and save the prefix wrapped in quote marks
elseif mw.ustringstring.find (line, 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif mw.ustringstring.find (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
descriptions[#descriptions] = mw.ustringstring.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. mw.ustringstring.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
end
end
local in_comments = false;
if mw.ustringstring.find (record, 'Deprecated') or mw.ustringstring.find (record, 'Preferred%-Value') or mw.ustringstring.find (record, 'Private use') then
return 'skip';
end
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
if mw.ustringstring.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = mw.ustringstring.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code
elseif mw.ustringstring.find (line, 'Description: .+') then -- if this line is a description line
table.insert (descriptions, '\"' .. mw.ustringstring.match (line, 'Description: (.+)') .. '\"'); -- extract and save the name wrapped in quote marks
elseif mw.ustringstring.find (line, 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif mw.ustringstring.find (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
descriptions[#descriptions] = mw.ustringstring.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. mw.ustringstring.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
end
end
for record in string.gmatch (content, '%%%%([^%%]+)') do -- get a %% delimited 'record' from the file; leave off the delimiters
if mw.ustringstring.find (record, 'Type: language') then -- if a language record
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
end
elseif mw.ustringstring.find (record, 'Type: script') then -- if a script record
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
end
elseif mw.ustringstring.find (record, 'Type: region') then -- if a region record
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
end
elseif mw.ustringstring.find (record, 'Type: variant') then -- if a region record
code, prefixes, descriptions = get_variant_parts (record); -- get the code, prefix(es), and description(s)
|