Mòideal:ISO 639/data/altnames/make
Coltas
(deasbaireachd⧼tpt-languages-separator⧽ ⧼tpt-languages-separator⧽eachdraidh⧼tpt-languages-separator⧽ceanglaichean⧼tpt-languages-separator⧽doc⧼tpt-languages-separator⧽bogsa-gainmhich⧼tpt-languages-separator⧽cùisean deuchainn)
This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
Please update Mòideal:ISO 639/data using Mòideal:ISO 639/data/make FIRST!
- Open a blank sandbox page and paste
{{#invoke:ISO 639/data/altnames/make|extract|file-date=YYYYMMDD}}
into it at the top line. - Where YYYYMMDD is year, month, day from the .tab filename
- Go to sil.org (ISO 639-3) and download the Complete Code Tables Set UTF-8 version zip file
- Unzip the zip file and open iso-639-3_Name_Index_YYYYMMDD.tab with a plain-text editor (such as notepad or notepad++)
- Copy the data from the editor and paste it into the sandbox page below the
{{#invoke:ISO 639/data/altnames/make|extract|file-date=YYYYMMDD}}
- Click Show preview or Publish changes
- Wait
- Get result (If needed copy them to Mòideal:ISO 639/data/altnames)
You can use this sandbox Module talk:ISO 639/data/altnames/sandbox
-- Keep Here
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"];
local data = mw.loadData("Module:ISO 639/data")
local remove = {["-"]="DASH",[" "]="SPACE",["%("]="BRAKCETOPEN",["%)"]="BRACKETCLOSE",["'"]="APOSTROPHE",["’"]="APOSTROPHE2",["’"]="APOSTROPHE2",["_"]="UNDERLINE",[","]="COMMA"}
local add = {["DASH"]="-",["SPACE"]=" ",["BRAKCETOPEN"]="(",["BRACKETCLOSE"]=")",["APOSTROPHE"]="'",["APOSTROPHE2"]="’",["APOSTROPHE2"]="’",["UNDERLINE"]="_",["COMMA"]=","}
for k,v in pairs(remove) do
content = mw.ustring.gsub(content,k,v)
end
for code, print, invert in mw.ustring.gmatch (content, '\n(%w%w%w)\t*(%w*)\t*(%w*)') do
local name = data[code].name
for k,v in pairs(remove) do
name = mw.ustring.gsub(name,k,v)
end
local print = string.gsub (print ,name,"")
local invert = string.gsub (invert ,name,"")
if print == invert then
invert = ""
end
--if print == mw.ustring.match (print,"%a+%A+%a+") then
-- print = mw.ustring.gsub (print," ","","")
--end
if invert ~= "" then
for k,v in pairs(add) do
invert = mw.ustring.gsub(invert,k,v)
end
table.insert(lang_table,"[\"" .. invert .. "\"] = \"" .. code .. "\"");
end
if print ~= "" then
for k,v in pairs(add) do
print = mw.ustring.gsub(print,k,v)
end
table.insert(lang_table,"[\"" .. print .. "\"] = \"" .. code .. "\"");
end
end
return "<br /><pre>-- " .. file_date .. "<br>-- ["Name"] = {"Part 3"} <br>-- You can update the code using [[Module:ISO 639/data/altnames/make]]<br>-- For more information about ISO 639 see [[ISO 639]]<br><br>return {<br />	" .. table.concat (lang_table, ',<br />	') .. "<br />	}<br />" .. "</pre>";
end
return p;