Modul:asoslari

Vikilug‘atdan olingan

Bu modul uchun Modul:asoslari/doc nomli hujjat sahifasini yaratishingiz mumkin

local b = {}

-- Biz bu soʻz uchun eliziya qilish kerak?
function b.is_elidable(mot)
    if (mw.ustring.match( mot, "^[aáàâäeéèêëiíìîïoóòôöuúùûüǘǜ]" ) ~= nil) then
        return true
    else
        return false
    end
end

-- Bu ibora emasmi?
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
    -- Bu mavjudligini tekshirish uchun boʻlgan sahifa sarlavhasi bilan obʼekt "mw.title" yaratadi
    local article = mw.title.new(titre)
    return article.exists
end

-- (Matn oʻzbek boʻlsa) birinchi harfi bilan qaytadi matn kapitallashtirilmaydi
function b.ucfirst(texte)
    if (texte == nil) then return texte end
    return (mw.ustring.gsub(texte, "^([’ǂǃǀǁ]*.)", b.uc))
end
-- (Matn oʻzbek boʻlsa) birinchi harfi kichik harflar bilan matn qaytadi
function b.lcfirst(texte)
    if (texte == nil) then return texte end
    locale = mw.tillar.new('fr')
    return locale:lcfirst(texte)
end
-- (Matn oʻzbek boʻlsa) katta matnni qaytadi
function b.uc(texte)
    if (texte == nil) then return texte end
    locale = mw.tillar.new('fr')
    return locale:uc(texte)
end
-- (Matn oʻzbek boʻlsa) kichik harflar matnni qaytaradi
function b.lc(texte)
    if (texte == nil) then return texte end
    locale = mw.tillar.new('fr')
    return locale:lc(texte)
end

-- U bir kontent sahifaga bo'lsa rost qaytaradi (asosiy, jadval, tezaurus)
function b.page_de_contenu()
    local ns = mw.title.getCurrentTitle().namespace
    
    -- 0 = normal, 100 = ilova, 106 = Tezaurus
    if ns == 0 or ns == 100 or ns == 106 then
        return true
    else
        return false
    end
end

-- Ziyoli sinfi qaytadi
function b.fait_categorie(texte, clef, ecrite)
    local cat = ecrite and ':Turkum:' or 'Turkum:'
    
    if (texte ~= nil) then
        if (clef ~= nil and clef ~= '') then
            return '[[' .. cat .. texte .. '|' .. clef .. ']]'
        else
            return '[[' .. cat .. texte .. ']]'
        end
    else
        return ''
    end
end

-- Normal, qoʻshimcha, tezaurus: u bir asosiy kosmosda boʻlsa, yaxshi shakllangan sinfini qaytadi
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

-- (Parametr unvonlar bilan) sortable stol vikida ismlariga yaratish
function b.tableau_entete(titres)
    local entete = '{| class="wikitable sortable"\r\n'
    entete = entete .. '|-\r\n!' .. table.concat(titres, ' !! ')
    return entete
end

-- Onlayn Wiki suhbati yaratadi
function b.tableau_ligne(elements)
    local ligne = '|-\r\n|' .. table.concat(elements, ' || ')
    return ligne
end

-- Qator uchini yaratadi
function b.tableau_fin()
    return "|}\r\n"
end

-- Darajada matn
function b.exposant(txt)
    return '<sup style="font-size:83%;line-height:1">'..txt..'</sup>'
end

-- chet tilida yozilgan bir matnni yorliqlarini
function b.balise_tili(txt, code)
	return '<span tili="' .. code .. '">' .. txt .. '</span>'
end

-- Mustaqil oʻzgarmaydigan etkazib barcha parametrlarni ikki tomonida joylar olib tashlash
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