Module:Tale-translit

Hello, you have come here looking for the meaning of the word Module:Tale-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Tale-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Tale-translit in singular and plural. Everything you need to know about the word Module:Tale-translit you have here. The definition of the word Module:Tale-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Tale-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate text in the Tai Nüa script. It is used to transliterate Tai Nüa. The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:Tale-translit/testcases.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

local gsub = mw.ustring.gsub
local u = require("Module:string/char")

local export = {}

-- pattern ()(?)(?)(?)

local tt = {
	-- consonants
	 = "k",  = "x",  = "ng",  = "ts",  = "s",  = "y",
	 = "t",  = "th",  = "l",  = "p",  = "ph",  = "m",
	 = "f",  = "w",  = "h",  = "ʼ",  = "kh",  = "tsh",  = "n",
	-- vowels
	 = "aa",  = "i",  = "e",  = "ae",  = "u",
	 = "o",  = "oa",  = "ue",  = "oe",  = "aue",
	 = "y",
}

local tone_table = {
	-- different ordering from Unicode: http://www.seasite.niu.edu/tai/TaiDehong/index.htm
	-- also supports old orthography
	 = u(0x0308),  = u(0x0308),  = u(0x0308), -- 2 ä
	 = u(0x030C),  = u(0x030C),  = u(0x030C), -- 3 ǎ
	 = u(0x0300),  = u(0x0300),  = u(0x0300),  = u(0x0300), -- 4 à
	 = u(0x0307),  = u(0x0307),  = u(0x0307), -- 5 ȧ
	 = u(0x0301),  = u(0x0301),  = u(0x0301),  = u(0x0301), -- 1 á
	 = "", -- 6 a
}

local tone_key = "([ᥰ-ᥴ"
	.. u(0x0308) .. u(0x00A8)
	.. u(0x030C) .. u(0x02C7)
	.. u(0x0300) .. u(0x0060) .. u(0x02CB)
	.. u(0x0307) .. u(0x02D9)
	.. u(0x0301) .. u(0x00B4) .. u(0x02CA) .. "]?)"

function export.tr(text, lang, sc)

	if type(text) == "table" then -- called directly from a template
		text = text.args
	end

	text = gsub(text, "()()", "%1a%2")
	text = gsub(text, ".", tt)

	-- adds tone diacritic
	local new
	for old in mw.text.gsplit(text, " ") do
		new = gsub(old, "()(*)" .. tone_key, function(v, x, t)
			return v .. tone_table .. x
			end)
		text = gsub(text, old, new, 1)
	end

	return text

end

return export