Moduł:IPA

 Dokumentacja modułu[zobacz] [edytuj] [historia] • [odśwież] • § podstrony

Moduł techniczny wspierający działanie szablonu {{IPA}}.

preprocess

Funkcja dekorująca zapis wymawianych dźwięków na linki do odpowiadających im artykułów. Funkcja pobiera zapis z parametru {{{1}}} przekazanego do szablonu {{IPA}}. Mapa dźwięków i odpowiadających im artykułów znajduje się w module danych Moduł:IPA/data.

Błędy

Błędy należy zgłaszać na stronie Wikipedia:Kawiarenka/Kwestie techniczne.

Zobacz też

return {
	
	preprocess = function (frame)
		local arg = frame:getParent().args[1]
		if not arg  then
			-- missing arguments
			return nil
		end
		
		if #arg == 0 then
			-- empty argument
			return nil
		end
		
		if not mw.ustring.isutf8(arg) then
			-- invalid input is left as is
			return arg
		end
		
		local ipadata = mw.loadData( 'Moduł:IPA/data' )
	 
		local split = function(text)
			local result = {}
			local joined = false
			local current = ""
			for code in mw.ustring.gcodepoint(text) do
				local c = mw.ustring.char(code)
				if ipadata.joining[code] then
					current = current .. c
					joined = true
				elseif joined or ipadata.combining[code] then
					current = current .. c
					joined = false
				else
					if current ~= "" then
						table.insert(result, current)
					end
					current = c
				end
			end
	 
			-- append last part
			if current ~= "" then
				table.insert(result, current)
			end
	 
			return result
		end
	 
		local decorate = function(parts)
			local last = false
			local currentLink = nil
			local result = {}
			local count = #parts
			local unknown = false
			table.insert(parts,"") -- append empty text to simplify loop below
			local i = 1
			while i <= count do
				local s, n = parts[i]..parts[i+1], 2
				local t = ipadata.sounds[s]
				if not t then
					s, n = parts[i], 1
					t = ipadata.sounds[s]
				end
	 
				local link = nil
				if t then
					t = t.see and ipadata.sounds[t.see] or t
					link = ((t.last and last) and last[t.last] or t.link) or ipadata.unknownSound
					last = t.last and last or t
				elseif mw.ustring.match(s,"[^%s']") then
					unknown = true
					s = mw.text.nowiki(s)
					link = ipadata.unknownSound
					last = false
				else
					last = false
				end
	 
				-- append the optional title
				if link ~= currentLink then
					if currentLink then
						table.insert(result,"]]")
						currentLink = nil
					end
					if link then
						table.insert(result,"[[")
						table.insert(result,link)
						table.insert(result,"|")
						currentLink = link
					end
				end
	 
				-- append the sound
				table.insert(result,s)
	 
				-- move to next sound in the input
				i = i + n
			end
	 
			if currentLink then
				table.insert(result, "]]")
			end
	 
			if unknown
			and (mw.title.getCurrentTitle().namespace == 0)
			then
				table.insert(result,ipadata.checkCat)
			end
			
			return table.concat(result,"")
		end
	 
		local parts = split(arg)
		local result = decorate(parts)
		return result
	end,

}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.
Kembali kehalaman sebelumnya