Модул:пойгоҳҳои
Documentation for this module may be created at Модул:пойгоҳҳои/doc
local b = {}
-- Бояд ба ин калимаро ба даст оред?
function b.is_elidable(mot)
if (mw.ustring.match( mot, "^[aàâäeéèêëiîïoôöuùûü]" ) ~= nil) then
return true
else
return false
end
end
-- Оё ин ибора?
function b.is_locution(mot)
if mot==nil then return nil end
if (mw.ustring.find(mot, ". .") ~= nil) then
return true
else
return false
end
end
function b.page_existe(titre)
if titre == nil then return nil end
-- Ин меорад объекти «mw.title» бо унвони саҳифаи аз он аст, ки ба тафтиши мавҷудияти
local article = mw.title.new(titre)
return article.exists
end
-- Бармегардад, ки матн бо ҳарфи аввал ба капитализатсия (агар матн аст, дар тоҷикӣ)
function b.ucfirst(texte)
if (texte == nil) then return texte end
locale = mw.language.new('fr')
return locale:ucfirst(texte)
end
-- Бармегардад, ки матн бо ҳарфи аввал сатри (агар матн аст, дар тоҷикӣ)
function b.lcfirst(texte)
if (texte == nil) then return texte end
locale = mw.language.new('fr')
return locale:lcfirst(texte)
end
-- Бармегардад матн ба харфои (агар матн аст, дар тоҷикӣ)
function b.uc(texte)
if (texte == nil) then return texte end
locale = mw.language.new('fr')
return locale:uc(texte)
end
-- Бармегардад матни сатри (агар матн аст, дар тоҷикӣ)
function b.lc(texte)
if (texte == nil) then return texte end
locale = mw.language.new('fr')
return locale:lc(texte)
end
-- Ҳақ бар мегардонад, агар яке дар саҳифаи мундариҷа аст (асосии, ҷадвал, луғати)
function b.page_de_contenu()
local ns = mw.title.getCurrentTitle().namespace
-- 0 = муқаррарӣ, 100 = Замимаи, 106 = луғати
if ns == 0 or ns == 100 or ns == 106 then
return true
else
return false
end
end
-- Як синф таҳсил бар мегардонад
function b.fait_categorie(texte, clef, ecrite)
local cat = ecrite and ':Гурӯҳ:' or 'Гурӯҳ:'
if (texte ~= nil) then
if (clef ~= nil and clef ~= '') then
return '[[' .. cat .. texte .. '|' .. clef .. ']]'
else
return '[[' .. cat .. texte .. ']]'
end
else
return ''
end
end
-- Бармегардад синфи соҳибмаърифат, агар он дар як фазои асосӣ аст: муқаррарӣ, замима, луғати тафсири
function b.fait_categorie_contenu(texte, clef, ecrite)
if b.page_de_contenu() then
return b.fait_categorie(texte, clef, ecrite) or ''
else
return ''
end
end
-- Эҷод сарлавҳаи як вики мизи (бо нишондоди унвонҳои)
function b.tableau_entete(titres)
local entete = '{| class="wikitable sortable"\r\n'
entete = entete .. '|-\r\n!' .. table.concat(titres, ' !! ')
return entete
end
-- Эҷод вики хати диаграмма
function b.tableau_ligne(elements)
local ligne = '|-\r\n|' .. table.concat(elements, ' || ')
return ligne
end
-- Эҷод охири ќатори
function b.tableau_fin()
return "|}\r\n"
end
-- Матн дар суперскрипт
function b.exposant(txt)
return '<sup style="font-size:83%;line-height:1">'..txt..'</sup>'
end
-- Хориҷ ҷойҳои дар ҳар ду тарафи њамаи параметрњо пешниҳод дар arg
function b.trim_parametres(args)
if args==nil then return nil end
local trim_args = {}
for k, v in pairs(args) do
trim_args[k] = mw.text.trim(v)
end
return trim_args
end
return b