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:Plural switch

  • Modul
  • Müzakirə

Bu modulun sənədləşdirmə səhifəsi Modul:Plural switch/doc səhifəsində yaradıla bilər

local p = {}

function p.plural(frame)
	local text          = frame.args[1]
	local text_singular = frame.args[2]
	local text_plural   = frame.args[3]

	local is_ident = false
	local is_plural = false

	-- принудительная установка
	if not is_ident then
		if string.find(text, 'data%-plural="0"') then is_plural = false; is_ident = true; end
		if string.find(text, 'data%-plural="1"') then is_plural = true;  is_ident = true; end
	end

	-- проверка по тегам
	if not is_ident and string.find(text, "<br") then is_plural = true; is_ident = true; end
	if not is_ident then
		_, count = string.gsub(text, "<li", "<li")
		if count > 1 then is_plural = true; is_ident = true; end
	end

	-- анализ текста
	if not is_ident then
		text = string.gsub(text, '%[%[.-%]%] <span lang=.-</span>', '') -- убираем расшифровки с других языков
		text = string.gsub(text, '%]<span.-</span></span>', '')         -- убираем шаблон нп3
		text = string.gsub(text, '<sup.-</sup>', '')   -- убираем верхние индексы
		text = string.gsub(text, '<.->', '')           -- убираем все теги
		text = string.gsub(text, '&[^&]-;', ' ')       -- заменяем спец. символы пробелами
		text = string.gsub(text, '%[%[Category.-%]%]', '') -- вырезаем ссылки на категории
		text = string.gsub(text, '%[%[File.-%]%]', 'img')  -- заменяем шаблоны-картинки (флаги)
		text = string.gsub(text, '%[%[Fayl.-%]%]', 'img')
		text = string.gsub(text, '%]%][a-z-]+%[%[', '')   -- склеиваем элементы рядом
		text = string.gsub(text, '%]%] +%[%[', '')
		text = string.gsub(text, '%[%[.-%]%]', 'x ')   -- считаем [[...]] одним элементом
		text = string.gsub(text, '%[.-%]', 'x ')       -- считаем [...] одним элементом
		text = string.gsub(text, '.."`UNIQ.-QINU`"..', '')     -- убираем специальные коды викиразметки + возможные замены [[...]]
		text = string.gsub(text, '[a-z]x', 'a')        -- сокращаем английские слова 
		text = string.gsub(text, '\n%*', ',')          -- звёздочка в начале - элемент списка
		text = string.gsub(text, 'x,%-x', 'x')         -- элементы-слова через дефис считаем одним
		text = string.gsub(text, '^ *,', '')           -- убираем первую запятую
		text = string.gsub(text, 'x.-x', 'x,x')        -- добавляем разделитель между x: x .. , .. x
		text = string.gsub(text, '[ \n]+$', '')        -- trim

		delimiters = {",", ";", "·", "•", "/", " и ", "\n"}
		for i,d in pairs(delimiters) do
			if not is_plural and string.find(text, d) then is_plural = true; is_ident = true; end
		end
	end

	-- формируем результат
	local result = text_singular
	if is_plural then result = text_plural end

	return result
end

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