Module:dar-translit

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

This module will transliterate Dargwa language text per WT:DAR 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:dar-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 mapping1 = {
	="b", ="p", ="f", ="v", ="m",
	="d", ="t", ="j", ="n", ="z", ="c",
	="s", ="ž", ="š", ="šč",
	="l", ="č", ="r", ="g", ="k", ="χ", 
	="ʾ", ="a", ="e", ="y", ="i", ="o", ="u", 
	="ë", ="’", ="e", ="ju", ="ə",
	="B", ="P", ="F", ="V", ="M",
	="D", ="T", ="J", ="N", ="Z", ="C",
	="S", ="Ž", ="Š", ="Šč",
	="L", ="Č", ="R", ="G", ="K", ="Χ", 
	="ʾ", ="A", ="E", ="Y", ="I", ="O", ="U", 
	="Ë", ="’", ="E", ="Ju", ="Ə"
}

local mapping2 = {
	 = 'ʒ',  = 'Ʒ',  = 'ǯ',  = 'Ǯ',
	 = 'ṗ',  = 'Ṗ',  = 'c̣',  = 'ṭ',
	 = 'č̣',  = 'q̇',  = 'ḳ',  = 'x',
	 = 'q',  = 'ɢ',  = 'γ',  = 'ʿ',
	 = 'ḥ',  = 'h',  = 'C̣',  = 'Ṭ',
	 = 'S̄',  = 'Č̣',  = 'Q̇',  = 'Ḳ',
	 = 'X',  = 'Q',  = 'ɢ',  = 'Γ',
	 = 'ʿ',  = 'Ḥ',  = 'H',
}

function export.tr(text, lang, sc)
	local str_gsub = string.gsub
	
	-- Convert capital to lowercase palochka. Lowercase is found in tables
	-- above.
	text = str_gsub(text, u(0x4C0), u(0x4CF))
	
	for pat, repl in pairs(mapping2) do
		text = str_gsub(text, pat, repl)
	end
	
	-- pattern for non-ASCII UTF-8 characters
	text = str_gsub(text, '+', mapping1)
	
	return text
end

return export