Module:Lingaedje/djivêye
Notule d' esplikêyes
Ci module ci sieve a dner l' djivêye des lingaedjes ki sont-st eredjistrés dins li dzo-pådje Module:Lingaedje/data. C' est on dzo-module do Module:Lingaedje k' i n' sieve a rén d' ôte.
Pask' i gn a bråmint des lingaedjes, on n' såreut fé tote el lisse d' on plin côp (gn a nén del memwere assez). Adon, li module fwait ene lisse sorlon li dzo-pådje k' i prind come indecse. Metans sol pådje Wiccionaire:Djivêye des lingaedjes/B, c' est B k' est prindou come clé et l' module dene tos les lingaedjes ki cminçnut pa cisse lete la. S'vi gn a pont di dzo-pådje, l' indecse serè A.
Fonccions po les pådjes
candjîbuild_html_table(1=index)
- Dene li tåvlea HTML avou
index
come lete etur A et Z (pitite u grande lete) {{#invoke:Lingaedje/djivêye|build_html_table|c}}
local p = {}
local l = require("Module:Lingaedje")
-- Display languages in a HTML table
-- sorted by lang code
function p.build_html_table(frame)
-- get the table of languages
local languages = mw.loadData('Module:Lingaedje/data')
local t = 0 -- total
local n = 0 -- not yet translated
if frame.args[1] == nil then
index= "a" -- default filter index
else
index = string.lower(frame.args[1])
end
-- sort lang code
langCode_sorted = {}
for code, lang in pairs(languages) do
if lang["name"] == "" then n = n + 1 end
t = t + 1
if(index == string.sub(code,1,1)) then
table.insert(langCode_sorted, code)
end
end
table.sort(langCode_sorted)
local az = ""
local azc = 65
local azp = ""
local azl = ""
while (azc < 65+26) do
if az ~= "" then az = az .. " - " end
azl = string.char(azc)
azp = mw.title.getCurrentTitle().nsText..":"..mw.title.getCurrentTitle().baseText..'/'..azl
if string.lower(azl) == index then
az = az .. "'''"..azl.."'''"
else
az = az .. '[['..azp..'|'..azl..']]'
end
azc = azc + 1
end
local t ='<div style="text-align:center;padding:.5em 0;">Gn a asteure '.. t .. " lingaedjes ('''mins "..n.." nén co ratournés''').</div>"
t = t ..'<div style="text-align:center;">'.. az .. '</div>\r\n'
t = t .. '{| class="wikitable sortable" style="width:700px;margin:1em auto;"\r\n'
t = t .. "|-\r\n!Côde!!No!!Drapea\r\n"
for i, code in pairs(langCode_sorted) do
flag = l.get_flag(code,true)
if flag == nil then flag = '' end
local langName = languages[code]["name"]
if langName == "" then
langName = '<span class="info">Nén co ratourné</span>'
end
t = t .. "|-\r\n"
t = t .. '| id="'..code..'" |'..code
t = t .. "||"..langName
t = t .. "||"..flag
t = t .. "\r\n"
end
t = t .. "|}\r\n"
return t
end
-- search language starting with str
-- output json entries for javascript query
function p.search_json(frame)
local str = frame.args[1]
str = mw.ustring.toNFD(str):gsub('[^a-z]', '')
local results = {}
if(str ~= nil and str ~= "") then
local languages = mw.loadData('Module:Lingaedje/data')
local t = 0
for code, lang in pairs(languages) do
local key = mw.ustring.toNFD(lang.name):gsub('[^a-z]', '')
if(lang.name ~= '' and code ~= "*" and code ~= "simboles" and
code ~= "s" and code ~= "wa" and
string.find(code, "wa-", 1, true ) == nil and
mw.ustring.find(key, str, 1, true) == 1) then
table.insert(results, {code,lang.name})
t = t + 1
end
if t == 10 then break end
end
end
results = mw.text.jsonEncode(results)
-- because [[...]] is considered as a link
-- replace by [ [...] ] for json output
results = mw.ustring.gsub(results, '%[%[', '[ [', 1)
results = mw.ustring.gsub(results, '%]%]', '] ]', 1)
return '<div>'..results..'</div>'
end
return p