بۆ ناوەڕۆک بازبدە

مۆدیوول:ISO 639/data/make

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
بەڵگەدارکردنی مۆدیوول[دروست بکە]
local p = {}

function p.extract (frame)
	local page = mw.title.getCurrentTitle();																	
	local content = page:getContent();																				
	local lang_table = {};																							
	local file_date = 'File-Date: ' .. frame.args["file-date"];
	
	content = mw.ustring.gsub (content,"-","DASH")
	content = mw.ustring.gsub (content," ","SPACE")
	content = mw.ustring.gsub (content,"%(","BRAKCETOPEN")
	content = mw.ustring.gsub (content,"%)","BRACKETCLOSE")
	content = mw.ustring.gsub (content,"'","APOSTROPHE")
	content = mw.ustring.gsub (content,"’","APOSTROPHE2")
	
	for part3, part2, part1, name in mw.ustring.gmatch (content, '\n(%w%w%w)\t(%w*)\t%a*\t(%w*)\t%a*\t%w*\t(%w*)') do
		
		name = mw.ustring.gsub (name,"DASH","-")
		name = mw.ustring.gsub (name,"SPACE"," ")
		name = mw.ustring.gsub (name,"BRAKCETOPEN","(")
		name = mw.ustring.gsub (name,"BRACKETCLOSE",")")
		name = mw.ustring.gsub (name,"APOSTROPHE","'")
		name = mw.ustring.gsub (name,"APOSTROPHE2","’")
		
		if part3 then
			if string.find (lang_table[#lang_table] or '', '^%[\"' .. part3) then								
				lang_table[#lang_table] = mw.ustring.gsub (lang_table[#lang_table], '}$', '');						
				lang_table[#lang_table] = lang_table[#lang_table] .. ', \"' .. "name" .. '\"}';							
			else
				table.insert (lang_table, 
					"[\"" .. part3 .. "\"] = {part2=\"" .. part2 .."\",part1 = \"" .. part1 .."\",name = \"" .. name .."\"}");		
			end
		else
			table.insert (lang_table, "[\"ERROR\"] = {" .. "ERROR" .. "}");					
		end
	end
	
	
	return "<br /><pre>-- " .. file_date .. "<br>-- [&quot;Part 3&quot;] = {part2=&quot;Part 2&quot;,part1=&quot;Part 1&quot;,name=&quot;Name&quot;} <br>-- You can update the code using [[Module:ISO 639/data/make]]<br>-- For more information about ISO 639 see [[ISO 639]]<br><br>return {<br />&#9;" .. table.concat (lang_table, ',<br />&#9;') .. "<br />&#9;}<br />" .. "</pre>";
end

return p;