Module:Alphabet

Iz Medžuviki, svobodnoj encyklopedije
Jump to navigation Jump to search

Nema teksta dokumentacije.

--
-- Module adds an ability to convert Interslavic text between two alphabets
-- It should be used in templates and modules to add an ability
-- to use then in Cyrillic alphabet
--
local p = {}
local data = mw.loadData('Module:Alphabet/data')

-- Cyrillic to Latin (use in other modules)
function p._latn(text)
	text = mw.text.decode(text)
	
	return (mw.ustring.gsub(text, '.', data.latn))
end

-- Cyrillic/Latin to ASCII Latin (use in other modules)
function p._ascii_latn(text)
	text = p._latn(text)
	
	return (mw.ustring.gsub(text, '.', data.ascii_latn))
end

-- Latin to Cyrillic (use in other modules)
function p._cyrl(text)
	text = mw.text.decode(text)
	
	return (mw.ustring.gsub(text, '.', data.cyrl))
end

-- Global Latin to Cyrillic (use in other modules)
function p._global_cyrl(text)
	if data.global_cyrl then
		return p._cyrl(text)
	end
	
	return text
end

-- Global Latin to Cyrl info (use in other modules)
function p._global_cyrl_info()
	return data.global_cyrl
end

-- Cyrillic to Latin conversion
function p.latn(frame)
	local text = frame.args[1]
	if text == nil or text == '' then
		return ''
	end
	
	return p._latn(text)
end

-- Cyrillic/Latin to ASCII Latin conversion
function p.ascii_latn(frame)
	local text = frame.args[1]
	if text == nil or text == '' then
		return ''
	end
	
	return p._ascii_latn(text)
end

-- Latin to Cyrillic conversion
function p.cyrl(frame)
	local text = frame.args[1]
	if text == nil or text == '' then
		return ''
	end
	
	return p._cyrl(text)
end

-- Global Latin to Cyrillic conversion
function p.global_cyrl(frame)
	local text = frame.args[1]
	if text == nil or text == '' then
		return ''
	end
	
	return p._global_cyrl(text)
end

-- Global Latin to Cyrl info
function p.global_cyrl_info(frame)
	return data.global_cyrl
end

return p