Module:ain-translit

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

This module will transliterate Ainu language text per WT:AIN TR. 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:ain-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 export = {}
local gmatch = mw.ustring.gmatch
local find = mw.ustring.find
local gsub = mw.ustring.gsub

local corresp = {
	-- main
	   = "¤a",    = "¤i",    = "¤u",    = "¤e",    = "¤o",
	   = "ka",    = "ki",    = "ku",    = "ke",    = "ko",
	 = "sa",    = "si",  = "su",  = "se",  = "so",
	   = "ta",    = "ci",    = "tu",    = "te",    = "to",
	 = "ca",                     = "cu",    = "ce",  = "co",
	   = "na",    = "ni",    = "nu",    = "ne",    = "no",
	   = "ha",    = "hi",    = "hu",    = "he",    = "ho",
	   = "ba",    = "bi",    = "bu",    = "be",    = "bo",
	   = "pa",    = "pi",    = "pu",    = "pe",    = "po",
	   = "ma",    = "mi",    = "mu",    = "me",    = "mo",
	   = "ya",                     = "yu",  = "ye",    = "yo",
	   = "ra",    = "ri",    = "ru",    = "re",    = "ro",
	   = "wa",  = "wi",                   = "we",  = "wo",

	-- finals
	 = "h¤",  = "h¤",  = "h¤",  = "h¤",  = "h¤",
	 = "r¤",  = "r¤",  = "r¤",  = "r¤",  = "r¤",
	 = "k¤",
	 = "s¤",
	 = "t¤",
	 = "n¤",
	 = "m¤",
	 = "p¤",

	-- misc
	 = "y¤",  = "w¤",
	 = "̄",
	 = "=",

	-- alt spellings
	 = "sa",  = "su",  = "se",  = "so",
	 = "tu",
	 = "cu",  = "ce",
	 = "wi",  = "we",  = "wo",
	 = "s¤",
	 = "x¤",
	 = "n¤",
	 = "tu",
	
	-- dialectal characters
	 = "zya",  = "zi",  = "zyu",  = "zye",  = "zyo",
	 = "da",					  = "du",  = "de",  = "do",
	 = "ga",  = "gi",  = "gu",  = "ge",  = "go",
	
	-- loanword characters
	 = "zi",  = "zya",  = "zyu",  = "zye",  = "zyo",
	 = "di",
	 = "za",                    = "zu",  = "ze",  = "zo"
}

function export.tr(text, lang, sc)
	local result = {}
	for string in gmatch(text, '.?') do
		if corresp then -- try to convert character sequences
			string = corresp
		else
			local str_result = {}
			for char in gmatch(string, '.') do -- try again over every individual character
				table.insert(str_result, corresp or char)
			end
			string = table.concat(str_result)
		end
		table.insert(result, string)
	end
	text = table.concat(result)
	text = mw.ustring.toNFC(text)

	if find(text, 'x¤') then -- 'ッ'
		text = gsub(text, 'x¤()', '%1¤%1')
	else
		text = gsub(text, 'x¤', 't¤')
	end

	text = gsub(text, '¤', '')

	return text
end
 
return export