مندرجات کا رخ کریں

ماڈیول:Lan

آزاد دائرۃ المعارف، ویکیپیڈیا سے
Documentation icon دستاویز [تخلیق]
local l = {}

function l._main ( args , frame )
    local langCode = args[1] -- Expects the language code as the first argument (e.g., 'en', 'ar')
    if not langCode then
        return '' -- Return empty if no language code provided
    end

    -- Attempt to fetch the language name using MediaWiki's built-in function
    -- This will return the name of the language (e.g., "English", "العربية") in the content language of the wiki (Urdu).
    local langName = mw.language.fetchLanguageName( langCode, mw.getContentLanguage():getCode() )

    -- Fallback to the language code itself if a name isn't found
    return langName or langCode
end

function l.main ( frame )
    local getArgs = require('Module:Arguments').getArgs
    local args = getArgs( frame, { parentFirst = true } )
    -- Pass the first unnamed argument (which should be the lang code) to _main
    return l._main( { args[1] }, frame )
end

return l