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

Content deleted Content added
+suppressed script extraction;
optimizations
Line 41:
local in_comments = false;
 
if string.find (record, 'Deprecated', 1, true) or string.find (record, 'Preferred%-Value'), 1, true)
or string.find (record, 'Private use', 1, true) then
return 'skip';
end
 
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
local before_colon = string.match(line, "(.-):")
if string.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = string.match (line, 'Subtag: ([%a%d]+)'); -- extract and save to subtag's code
elseifif not before_colon and string.find (line, 'Description:^ .+') and not in_comments then -- if thisa continuation line isbut not a descriptioncomments linecontinuation
descriptions[#descriptions] = string.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. string.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
ifelseif string.findbefore_colon (line,== 'Subtag: [%a%d]+') then -- if this line is the subtag line
code = string.match (line, 'Subtag: ([%a%d]w+)'); -- extract and save to subtag's code
ifelseif string.findbefore_colon (line,== 'Subtag: [%a%d]+Description') then -- if this line is thea subtagdescription line
local desc = string.match (line, 'Description: (.+)'); -- extract the description
desc = string.gsub (desc, '"', '\\"'); -- in case description contains quote marks (see 1959acad)
table.insert (descriptions, '\"' .. desc .. '\"'); -- save the description wrapped in quote marks
elseif string.findbefore_colon (line,== 'Prefix: .+') then -- if this line is a prefix line
table.insert (prefixes, '\"' .. string.match (line, 'Prefix: (.+)'):lower() .. '\"'); -- extract and save the prefix wrapped in quote marks
elseif string.findbefore_colon (line,== 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif string.find (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
descriptions[#descriptions] = string.gsub (descriptions[#descriptions], '\"$', ''); -- remove trailing quote mark from previous description
descriptions[#descriptions] = descriptions[#descriptions] .. ' ' .. string.match (line, '^ (.+)') .. '\"'; -- extract and save the continuation with new quote mark
end
end
Line 106 ⟶ 109:
 
for line in string.gmatch (record, '([^\n]+)\n') do -- get a \n terminated line of text (without the \n)
local before_colon = string.match(line, "(.-):")
if string.find (line, 'Subtag: [%a%d]+') then -- if this line is the subtag line
codeif before_colon == string.match (line, 'Subtag: ([%a%d]+)'); then -- extractif andthis saveline tois the subtag's codeline
elseif code = string.findmatch (line, 'DescriptionSubtag: .(%w+)') then ; -- ifextract thisand linesave isto asubtag's description linecode
elseif before_colon == 'Description' then -- if this line is a description line
table.insert (descriptions, '\"' .. string.match (line, 'Description: (.+)') .. '\"'); -- extract and save the name wrapped in quote marks
elseif string.findbefore_colon (line,== 'Suppress%-Script: %S+') then
suppress = string.match (line, 'Suppress%-Script: (%S+)');
elseif string.findbefore_colon (line,== 'Comments: .+') then -- if this line is a comments line
in_comments = true;
elseif string.find (line, '^ .+') and not in_comments then -- if a continuation line but not a commnets continuation
Line 154 ⟶ 158:
 
for record in string.gmatch (content, '%%%%([^%%]+)') do -- get a %% delimited 'record' from the file; leave off the delimiters
iflocal record_type = string.find match(record, 'Type: language(%w+)') then -- if a language record
if record_type == 'language' then -- if a language record
code, descriptions, suppress = get_lang_script_region_parts (record); -- get the code, description(s), and suppress script
Line 175 ⟶ 180:
end
 
elseif string.findrecord_type (record,== 'Type: script') then -- if a script record
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
Line 184 ⟶ 189:
end
 
elseif string.findrecord_type (record,== 'Type: region') then -- if a region record
code, descriptions = get_lang_script_region_parts (record); -- get the code and description(s)
Line 193 ⟶ 198:
end
 
elseif string.findrecord_type (record,== 'Type: variant') then -- if a regionvariant record
code, prefixes, descriptions = get_variant_parts (record); -- get the code, prefix(es), and description(s)