Module:tab-translit

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

This module will transliterate Tabasaran language text per WT:TAB 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:tab-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 u = require("Module:string/char")

local export = {}

local tt = {
	="b", ="p", ="f", ="v", ="m",
	="d", ="t", ="j", ="n", ="z", ="c",
	="s", ="ž", ="š", ="šč", 
	="l", ="č", ="r", ="g", ="k", ="ꭓ", 
	="ʾ", ="a", ="e", ="y", ="i", ="o", ="u", 
	="ë", ="ʼ", ="e", ="ju", ="ja",
	="B", ="P", ="F", ="V", ="M",
	="D", ="T", ="J", ="N", ="Z", ="C",
	="S", ="Ž", ="Š", ="Šč", 
	="L", ="Č", ="R", ="G", ="K", ="Ꭓ", 
	="ʾ", ="A", ="E", ="Y", ="I", ="O", ="U", 
	="Ë", ="ʼ", ="E", ="Ju", ="Ja"};

local trigraphs = {
	 = "q°",
	 = "Q°",
	 = "q̄°",
	 = "Q̄°",
	 = "q̇°",
	 = "Q̇°",
	 = "ġ°",
	 = "Ġ°",
	 = "ḳ°",
	 = "Ḳ°",
	 = "k̄°",
	 = "K̄°",
}

local digraphs = {
	 = "ž°",
	 = "Ž°",
	 = "č°",
	 = "Č°",
	 = "č̄°",
	 = "Č̄°",
	 = "č̣",
	 = "Č̣",
	 = "š°",
	 = "Š°",
	 = "ꭓ°",
	 = "Ꭓ°",
	 = "p̄",
	 = "P̄",
	 = "ṗ",
	 = "Ṗ",
	 = "t̄",
	 = "T̄",
	 = "c̣",
	 = "C̣",
	 = "c̄",
	 = "C̄",
	 = "ṭ",
	 = "Ṭ",
	 = "č̄",
	 = "Č̄",
	 = "č̣",
	 = "Č̣",
	 = "q̇",
	 = "Q̇",
	 = "k̄",
	 = "K̄",
	 = "ḳ",
	 = "Ḳ",
	 = "q",
	 = "Q",
	 = "q̄",
	 = "Q̄",
	 = "ġ",
	 = "Ġ",
	 = "h",
	 = "H",
	 = "u̱",
	 = "U̱",
	 = "x",
	 = "X",
	 = "g°",
	 = "G°",
	 = "k°",
	 = "K°",
	 = "a̱",
	 = "A̱",
}

function export.tr(text, lang, sc)
	local str_gsub = string.gsub
	local UTF8char = "*"
	
	-- Convert uppercase palochka to lowercase. Lowercase is found in tables
	-- above.
	text = str_gsub(text, u(0x4C0), u(0x4CF))
	
	for trigraph, translit in pairs(trigraphs) do
		text = str_gsub(text, trigraph, translit)
	end
	
	for digraph, translit in pairs(digraphs) do
		text = str_gsub(text, digraph, translit)
	end
	
	text = str_gsub(text, UTF8char, tt)
	
	return text
end

return export