Butun axtardiqlarinizi tapmaq ucun buraya: DAXIL OLUN
  Mp4 Mp3 Axtar Yukle
  Video Axtar Yukle
  Shekil Axtar Yukle
  Informasiya Melumat Axtar
  Hazir Inshalar Toplusu
  AZERI CHAT + Tanishliq
  1-11 Sinif Derslikler Yukle
  Saglamliq Tibbi Melumat
  Whatsapp Plus Yukle(Yeni)

  • Ana səhifə
  • Təsadüfi
  • Yaxınlıqdakılar
  • Daxil ol
  • Nizamlamalar
İndi ianə et Əgər Vikipediya sizin üçün faydalıdırsa, bu gün ianə edin.

Modul:Languages

  • Modul
  • Müzakirə
Sənədləşdirmə
[bax | | tarixçə | yenilə]
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.

Bu moduldan {{l6e}} şablonunda dil keçidləri yaradarkən istifadə olunur: {{#invoke:Languages|list|müxtəlif dillər}}.

Moduldan müxtəlif dil kodlarının mübadiləsində də istifadə olunur.

Sınaqlar

2 testdə xəta baş verdi.

test_getRefHtml:

Mətn Gözlənilən Aktual
✅Y {{#invoke:Languages | getRefHtmlFrame | }}
✅Y {{#invoke:Languages | getRefHtmlFrame | QNNN }}
❌N {{#invoke:Languages | getRefHtmlFrame | Q1860 }} (ing.) (ing.)
❌N {{#invoke:Languages | getRefHtmlFrame | Q7737 }} (rus.) (rus.)



Səhifə xətalarının olmaması üçün bu şablon üzərində təcrübələri öz şəxsi səhifənizdə aparmağınız məsləhət görülür.

-- Модуль для работы с языками ISO 639

local languages = mw.loadData('Module:Languages/data')
local p = {}

local function isEmpty(s)
	return s == nil or s == ''
end

local function trimstr(s)
  return (s:gsub("^%s*(.-)%s*$", "%1"))
end

local function get_lang_data(code)
    local l = languages[code];
    if l ~= nil then
        return "[[" .. l[2] .. "|" .. l[1] .. "]]", code
    elseif code ~= "" then
        return code, ""
    else
        return "", ""
    end
end

function p.getRefHtmlFrame( frame )
	return p.getRefHtml( trimstr( frame.args[1] ) )
end

function p.getRefHtml( wikidataItemId )
	local codeByItemId = mw.loadData( "Module:Wikidata/Language-codes" )
	local code = codeByItemId[ wikidataItemId ];
	if code == nil then
		mw.log( 'Language code not found for ' .. wikidataItemId )
		return ""
	else
    	local l = languages[code];
		if l == nil then
			mw.log( 'Language description for code ' .. code .. ' not found' )
	        return ""
	    else
	        return '<span class="ref-info" title="' .. l[ 2 ] .. '" style="cursor:help">(' .. l[ 1 ] .. ')</span>'
	    end
	end
end

function p.abbr(frame)
	local code = trimstr( frame.args[1] )
	if not isEmpty(code) then
		return (languages[code] and languages[code][1] or '')
	end
end

function p.name(frame)
	local code = trimstr( frame.args[1] )
	if code ~= nil and code ~= '' then
		return (languages[code] and languages[code][2] or '')
	end
end

function p.list(frame)
    local curr_lang = nil
    local result = nil

    for n, v in frame:argumentPairs() do
		local trimmed = trimstr(v)
		if curr_lang == nil then
		if trimmed ~= '' then
			-- если язык пропущен, оставим прошлый
			curr_lang = trimstr(v)
		end
		else
		if trimmed ~= '' then
			local link, lang_code = get_lang_data(curr_lang)
			local list_item
			if lang_code ~= '' then
				list_item = link .. "&nbsp;<span dir='auto' lang='" .. lang_code .. "'>" .. trimmed .. "</span>"
			else
				list_item = link .. " <span class='unknown-foreign-lang'>" .. trimmed .. "</span>".."[[Category:Vikipediya:Tanınmayan dil istifadə edilən səhifələr]]"
			end
			
			if result == nil then
				result = list_item
			else
				result = result .. ", " .. list_item
			end
		else

		local link, lang_code = get_lang_data(curr_lang)
		if result == nil then
			result = link
		else
			result = result .. ", " .. link
		end
		end
		
		curr_lang = nil
      end
    end
    
    if curr_lang ~= nil then
        local link, lang_code = get_lang_data(curr_lang)
        if result ~= nil then
            result = result .. ", " .. link
        else
            result = link
        end
    end
    return result
end

function p.list_ref(frame)
    local result = ''
    local v = frame.args['в'] or nil
	local ref = nil

	if v then
		ref = '&nbsp;<span class="ref-info" style="cursor:help;" title="%2%">&#091;%1%&#093;</span>'
	else
		ref = '&nbsp;<span class="ref-info" style="cursor:help;" title="%2%">(%1%)</span>'
	end

    for x, lg in pairs( frame.args ) do
		local code = trimstr(lg)
		if code ~= '' and code ~= 'в' then
			local l = languages[code]
			if l and l ~= nil then
				result = result .. mw.ustring.gsub(mw.ustring.gsub(ref, '%%2%%', p._transform_lang(code)), '%%1%%', l[1])
			else
				result = result .. frame:expandTemplate{ title = 'ref-' .. code } .. '[[Category:Vikipediya:Tanınmayan dil istifadə edilən səhifələr (ref)]]'
			end
		end
    end

    return result
end

function p._transform_lang(code)
	if isEmpty(languages[code]) then return '&lt;tanınmayan kod ' .. code .. '&gt;' end
    if languages[code][3] then return languages[code][3] end
    local ln = mw.ustring.lower(
        languages[code] and languages[code][2]
        or mw.language.fetchLanguageName(code,'az')
     ):gsub('%s+dili%s+',  ' '):gsub('%s*%(?dili%)?%s*',  '')
    if not ln then return 'ISO kodlu dil '..code..' (?)' end
    if ln:match('.*лингва$') then return ln:gsub('а$','е') end
    if mw.ustring.match(ln,'[сц]кий$') or ln:match('ный$') or mw.ustring.match(ln,'[сц]кий%s%b()$') or ln:match('ный%s%b()$')
    then
        ln = mw.ustring.gsub(
            mw.ustring.gsub(ln, 'н([ыи])й(%A)', function(y,s) return (y=='ы' and 'ном' or 'нем')..s end)
                :gsub('ный$', 'ном'),
            '([сц]к)ий(%A)', '%1ом%2'
        ):gsub('ский$', 'ском'):gsub('цкий$', 'цком');
        if ln:match('%)$') and not (ln:match('ом%)$') or ln:match('нем%)$')) -- «языке» перед уточнением, если оно не склоняется
        then 
            local r,s=ln:gsub('(%s)(%b())$','%1 %1%2');
            if s==1 then return r end
        end
        return ln..' dilində'
    else
        return ln..' dilində'
    end
end

function p.transform_lang(frame)
	return p._transform_lang(trimstr(frame.args[1]))
end

return p
Mənbə — "https://az.wikipedia.org/w/index.php?title=Modul:Languages&oldid=6106059"
Informasiya Melumat Axtar