Modul:girêdan
Belgekirina modulê[nîşan bide] [biguhêre] [rojane bike]
- Ev belge ji Modul:girêdan/belge hatiye girtin.
Bikaranîn
biguhêre- Di nav Modulan de
g = require('Modul:girêdan').giredan
g(kod, peyv, cuda)
+ translîterasyon
g = require('Modul:girêdan').giredan_translit
g(kod, peyv, cuda, tr, wate)
Dema ku peyv tûne ye, girêdayî dernakevî.
g = require('Modul:girêdan').gR
gR(kod, peyv, cuda, tr, wate)
- Şablon
local p = {}
b = require('Modul:bingeh')
m_languages = require("Modul:ziman")
local find = mw.ustring.find
--- bêkod
function bekod(str)
str = str or ""
str = mw.ustring.gsub(str, "<[^>]*>", "")
str = mw.ustring.gsub(str, "'''?", "")
return str
end
function p.bekod_sablon(frame)
local str = frame.args[1] or ""
str = mw.ustring.gsub(str, "<[^>]*>", "")
str = mw.ustring.gsub(str, "'''?", "")
return str
end
-- zim ([[Şablon:zim]])
function p.formatZiman(kod, peyv, sc)
local lang = m_languages.getByCode(kod)
local ziman = lang:getCanonicalName()
local classes
if (sc) then
classes = sc
else
classes = lang:getScriptCodes()[1]
end
return '<span lang="' .. kod .. '" xml:lang="' .. kod ..'" class="' .. classes .. '">' ..peyv .. '</span>'
end
-- translîterasyon
function p.g_translit(g_kod, g_peyv, g_tr)
local title = tostring(g_kod .. '-translit')
local translitLink = tostring('Modul:' .. title)
if mw.title.new( title, 'Modul' ).exists == true then
translit = require(translitLink).tr
end
if (g_tr and g_tr ~= '-' and g_tr ~= '') then
return g_tr
elseif (g_tr == '-') then
return ''
elseif ( (g_tr == '' or g_tr == nil) and translit and translit(g_peyv)) then
return translit(g_peyv)
else
return ''
end
end
-- girêdan
function p.giredan(kod, peyv, cuda)
local grd
if ( peyv == nil or peyv == '' ) then
peyv = kod
kod = 'ku'
end
if (peyv and kod) then
local lang = m_languages.getByCode(kod)
local ziman = lang:getCanonicalName()
if (find(bekod(peyv), '^%*')) then
grd = '[[' .. 'Jinûvesazî:' .. ziman .. '/' .. bekod(peyv) .. '|' .. peyv .. ']]'
elseif (cuda ~= nil and cuda ~= '') then
grd = '[[' .. bekod(peyv) .. '#' .. kod .. '|' .. cuda .. ']]'
else
grd = '[[' .. bekod(peyv) .. '#' .. kod .. '|' .. peyv .. ']]'
end
end
grd = p.formatZiman(kod, grd)
return grd
end
-- girêdan + translit + wate
function p.giredan_translit(kod, peyv, cuda, tr, wate)
local grd_translit
local gtranslit
-- Agadarî: "tr" (trasnliterasyon) hatiye nivîsandin feqet peyv ne hatiye nivîsandin
if ( tr and (peyv == nil or peyv == '' or peyv =='?') ) then
return '[<small style="color:green;">skrîpt hewce ye</small>] <i>(' .. tr .. ')</i>' .. b.bike_kategori_naverok('Peyvên ku skrîpt hewce ne ('.. ziman.get_nav(kod) .. ')')
end
-- Koda zimanî bo kurdî ne pêwîst e
if ( peyv == nil or peyv == '' ) then
peyv = kod
kod = 'ku'
end
-- translît.
if (cuda ~= nil and cuda ~= '') then
gtranslit = p.g_translit(kod, cuda, tr)
else
gtranslit = p.g_translit(kod, peyv, tr)
end
if (gtranslit and gtranslit ~='') then
if (wate and wate ~= '') then
grd_translit = p.giredan(kod, peyv, cuda) .. ' ' .. '(<i>' .. gtranslit ..'</i>, "' .. wate .. '")'
else
grd_translit = p.giredan(kod, peyv, cuda) .. ' ' .. '(<i>' .. gtranslit .. ')</i>'
end
else
-- wate û "tr" ne htiye nivîsandin
if (wate and wate ~= '') then
grd_translit = p.giredan(kod, peyv, cuda) .. ' ' .. '("' .. wate .. '")'
else
grd_translit = p.giredan(kod, peyv, cuda)
end
end
return grd_translit
end
-- Dema ku peyv tûne ye, girêdayî dernakevî (bo şablonan hatiye çêkirin).
function p.gR(kod, peyv, cuda, tr, wate)
if ( peyv == nil or peyv == '' ) then
peyv = kod
kod = 'ku'
end
peyv_bekod = bekod(peyv)
if ( mw.title.new( peyv_bekod, mw.site.namespaces[0].name ).exists == true ) then
return p.giredan_translit(kod, peyv, cuda, tr, wate)
else
cuda = '<span style="color:#222">' .. peyv .. '</span>'
return p.giredan_translit(kod, peyv, cuda, tr, wate)
end
end
--ji bo şablona şablon:g
function p.g(frame)
local face = frame.args["face"]
local allowSelfLink = frame.args["notself"]; allowSelfLink = not allowSelfLink or allowSelfLink == ""
local params = {
[1] = {required = true},
[2] = {},
[3] = {alias_of = "cuda"},
[4] = {alias_of = "wate"},
["cuda"] = {},
["wate"] = {},
["w"] = {alias_of = "wate"},
["z"] = {list = true},
["id"] = {},
["tr"] = {},
["ts"] = {},
["sc"] = {},
["accel-form"] = {},
["accel-translit"] = {},
["accel-lemma"] = {},
["accel-lemma-translit"] = {},
["accel-gender"] = {},
["accel-nostore"] = {type = "boolean"},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = args[1]
-- Tracking for missing language or und
if not lang then
require("Module:debug").track("link/no lang")
elseif lang == "und" then
require("Module:debug").track("link/und")
end
lang = lang or "und"
local sc = args["sc"]
local term = args[2]
local alt = args["cuda"]
-- Check parameters
lang = require("Modul:ziman").getByCode(lang, 1, "allow etym")
lang = require("Modul:ziman").getNonEtymological(lang)
if sc then
sc = require("Module:scripts").getByCode(sc, "sc")
end
if not term and not alt and not tr and lang == "und" then --ev naxebite
peyv = args[1]
return '[[' .. peyv .. '#Kurdî|' .. peyv .. ']]'
else
return require("Module:links").full_link(
{
lang = lang,
sc = sc,
term = term,
alt = args["cuda"],
id = args["id"],
genders = args["z"],
tr = args["tr"],
ts = args["ts"],
t = args["w"],
gloss = args["wate"],
accel = args["accel-form"] and {
form = args["accel-form"],
translit = args["accel-translit"],
lemma = args["accel-lemma"],
lemma_translit = args["accel-lemma-translit"],
gender = args["accel-gender"],
nostore = args["accel-nostore"],
} or nil,
},
face,
allowSelfLink
)
end
end
--ji bo şablona şablon:qal/şablon:q bi vê şablonê peyv îtalîk derdikeve
function p.qal(frame)
local face = frame.args["face"]
local allowSelfLink = frame.args["notself"]; allowSelfLink = not allowSelfLink or allowSelfLink == ""
local params = {
[1] = {required = true},
[2] = {},
[3] = {alias_of = "cuda"},
[4] = {alias_of = "wate"},
["cuda"] = {},
["wate"] = {},
["w"] = {alias_of = "wate"},
["id"] = {},
["tr"] = {},
["z"] = {list = true},
["ts"] = {},
["sc"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = args[1]
-- Tracking for missing language or und
if not lang then
require("Module:debug").track("link/no lang")
elseif lang == "und" then
require("Module:debug").track("link/und")
end
lang = lang or "und"
local sc = args["sc"]
local term = args[2]
local alt = args["cuda"]
-- Check parameters
lang = require("Modul:ziman").getByCode(lang, 1, "allow etym")
lang = require("Modul:ziman").getNonEtymological(lang)
if sc then
sc = require("Module:scripts").getByCode(sc, "sc")
end
if not term and not alt and not tr and lang == "und" then --ev naxebite
peyv = args[1]
return '[[' .. peyv .. '#Kurmancî|' .. peyv .. ']]'
else
return require("Module:links").full_link(
{
lang = lang,
sc = sc,
term = term,
alt = args["cuda"],
id = args["id"],
tr = args["tr"],
genders = args["z"],
ts = args["ts"],
t = args["w"],
gloss = args["wate"],
},
face,
allowSelfLink
)
end
end
-- Ji bo [[Şablon:g-]]
function p.gRes(frame)
local args = frame:getParent().args
local kod = args[1]
local peyv = args[2]
local cuda = args['cuda']
local tr = args['tr']
local wate = args['wate'] or args['w']
return p.gR(kod, peyv, cuda, tr, wate)
end
--ji bo şablon:pêk, şablon:têkilkirin hwd.
function p.g_parametre(frame)
local face = frame.args["face"]
local args = frame:getParent().args
local lang = frame.args['kod']
local term = frame.args['peyv']
local alt = args['cuda'] or args['cuda1']
local genders = args['z1'] or args['z']
local id = args['id1'] or args['id']
local tr = args['tr1'] or args['tr']
local gloss = args['wate'] or args['w'] or args['w1']
local ts = args['ts'] or args['R'] or args['ts1']
local sc = args['sc1'] or args['sc']
-- Tracking for missing language or und
if not lang then
require("Module:debug").track("link/no lang")
elseif lang == "und" then
require("Module:debug").track("link/und")
end
lang = lang or "und"
-- Check parameters
lang = require("Modul:ziman").getByCode(lang, 1, "allow etym")
lang = require("Modul:ziman").getNonEtymological(lang)
if sc then
sc = require("Module:scripts").getByCode(sc, "sc")
end
-- Forward the information to full_link
return require("Module:links").full_link(
{
lang = lang,
sc = sc,
term = term,
alt = alt,
id = id,
tr = tr,
ts = ts,
gloss = gloss,
genders = genders,
},
face
)
end
--ji bo şablon:pêk, şablon:têkilkirin hwd.
function p.g_parametre2(frame)
local face = frame.args["face"]
local args = frame:getParent().args
local lang = frame.args['kod']
local term = frame.args['peyv']
local alt = args['cuda2']
local tr = args['tr2']
local id = args['id2']
local genders = args['z2']
local gloss = args['w2']
local ts = args['ts2'] or args['R2']
local sc = args['sc2']
-- Tracking for missing language or und
if not lang then
require("Module:debug").track("link/no lang")
elseif lang == "und" then
require("Module:debug").track("link/und")
end
lang = lang or "und"
-- Check parameters
lang = require("Modul:ziman").getByCode(lang, 1, "allow etym")
lang = require("Modul:ziman").getNonEtymological(lang)
if sc then
sc = require("Module:scripts").getByCode(sc, "sc")
end
-- Forward the information to full_link
return require("Module:links").full_link(
{
lang = lang,
sc = sc,
term = term,
alt = alt,
id = id,
tr = tr,
ts = ts,
gloss = gloss,
genders = genders,
},
face
)
end
-- {{herekejêbibe}} ji bo jêbirina hereke/diacritikên peyvan
function p.herekejebibe(frame)
local args = frame:getParent().args
local lang = frame.args[1]
local term = frame.args[2]
lang = require("Modul:ziman").getByCode(lang, 1, "allow etym")
lang = require("Modul:ziman").getNonEtymological(lang)
if term then
peyv = lang:makeEntryName(term)
end
return peyv
end
return p