Module:User:Dixtosa
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: subpage list • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Dixtosa, for his own experimentation. Items in this module may be added and removed at Dixtosa's discretion; do not rely on this module's stability.
local export = {}
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
--Entry point
function export.GetLangNameToLangCodeMapping(prefix)
local byName = mw.loadData("Module:languages/by name")
local found_code = nil
local found_name = nil
for name, code in pairs(byName) do
if (string.starts(name, prefix.args[1])) then
if found_code == nil or found_code == code then
found_code = code
found_name = name
else
return ""
end
end
end
if found_code ~= nil then
return found_code..":"..found_name
else
return "" end
end
function export.GetAllData()
local byName = mw.loadData("Module:languages/by name")
return require("Module:JSON").toJSON(byName)
end
return export