Module:brh-translit

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

This module will transliterate Brahui language text. 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:brh-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 = mw.ustring.char
local gsub = mw.ustring.gsub
local export = {}

local zabar = U(0x64E)
local zer = U(0x650)
local pesh = U(0x64F)
local tashdid = U(0x651) -- also called shadda
local jazm = "ْ"
local he = "ہ"

local consonants = "ببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨوہھٹڈڑ"
local consonantS = "ببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨہھٹڈڑ"
local consonantS2 = "یببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨوہھٹڈڑ" 
local vowels = "ایئےۓوؤ"
local hes = "ہح"
local diacritics = "َُِّْٰ"
local ZZP = "َُِ"

local mapping = {
	 = 'ā',  = 'b',  = 'p',  = 't',  = 'ṭ',  = 's',
	 = 'j',  = 'c',  = 'h',  = 'x', 
	 = 'd',  = 'ḍ',  = 'z',  = 'r',  = "ṛ",  = 'z',  = 'ž',
	 = 's',  = 'ś',  = 's',  = 'z', 
	 = 't',  = 'z',  = 'ġ',  = 'f',  = 'q',
	 = 'k',  = 'g',  = 'ṇ',  = 'ḷ',
	 = 'l',  = 'ł',  = 'm',  = 'n',  = 'ō',  = 'h',  = 'y',  = 'ē',  = ".",  = '̃',

	 = "h",
	

	 = '‘',
	 = '’',
	 = '', 
	 = 'ō',
	 = '',
	
	-- diacritics
	 = "a",
	 = "i",
	 = "u",
	 = "", -- also sukun - no vowel
	 = "-", -- ZWNJ (zero-width non-joiner)
	
	-- ligatures
	 = "lā",
	 = "allāh",
	
	-- kashida
	 = "-", -- kashida, no sound
	
	-- numerals
	 = "1",  = "2",  = "3",  = "4",  = "5",
	 = "6",  = "7",  = "8",  = "9",  = "0",
	
	-- punctuation (leave on separate lines)
	 = "?", -- question mark
	 = ",", -- comma
	 = ";", -- semicolon
	 = '“', -- quotation mark
	 = '”', -- quotation mark
	 = "%", -- percent
	 = "‰", -- per mille
	 = ".", -- decimals
	 = ",", -- thousand
	 = "-ye", 
	 = "-e" -- he ye (in ezâfe)
}

local ain = 'ع'
local alif = 'ا'
local ye = 'ی'
local ye2 = 'ئ'
local ye3 = "ے"
local vao = "و"
local aspirate = 'ھ'

function export.tr(text, lang, sc)
	
	-- EXCEPTIONS - leave as they are, unless they have been sorted out elsewhere
	text = gsub(text, '()' .. ye .. "ں", "%1ē̃")
	text = gsub(text, zabar .. aspirate .. "(ی)" , "hɛ̄")
	text = gsub(text, zabar .. aspirate .. "(و)" , "hɔ̄")
	text = gsub(text, "ؤ" .. pesh, "ū")
	text = gsub(text, "وہ", "vo")
	text = gsub(text, alif .. ye2 .. '()', "ā'ya%1")

	-- Tashdeed
	text = gsub(text, '()' .. tashdid, "%1%1")
	text = gsub(text, '()' .. tashdid .. '()', "%1%1%2")
	text = gsub(text, '()' .. ye .. '()' .. tashdid, "%1yy%2")
	text = gsub(text, '()' .. vao .. '()' .. tashdid, "%1vv%2")
	-- For some reason the tashdeed gets pushed after the other diacritics, so this line is necessary for tashdeed to work with other diacritics
	text = gsub(text, '()' .. '()' .. tashdid, "%1%1%2")
	
	-- e, instead of i
	text = gsub(text, alif .. zer .. ain .. jazm .. '()' .. zer, "ē‘%1e")
	text = gsub(text, jazm .. '()' .. zer .. '()' .. alif, "%1e%2ā")
	text = gsub(text, alif .. zer .. ain .. jazm, "ē‘")
	
	-- tanween diacritic
	text = gsub(text, '()' .. 'ً' .. alif, "%1an")
	text = gsub(text, alif .. 'ً', "an")
	text = gsub(text, '()' .. 'ً', "%1an")

	-- khari zabar --
	text = gsub(text, '()' .. 'ٰ', "ā")
	text = gsub(text, '()' .. 'ٰ' .. '()', "%1ā")
	
	-- ‘ain
	text = gsub(text, alif .. ain , "ā‘") 
	text = gsub(text, ain .. alif  .. '()', "‘ā%1") 
	text = gsub(text, '()' .. ain .. he, "%1‘a")
	text = gsub(text, '()' .. '(?)' .. ain, "%1%2‘")
	text = gsub(text, ain .. zabar .. vao .. '()', "‘ɔ̄%1")
	text = gsub(text, ain .. zabar .. ye .. '()', "‘ɛ̄%1")
	text = gsub(text, ain .. zer  .. '()', "‘i%1")
	text = gsub(text, ain .. pesh  .. '()', "‘u%1")
	text = gsub(text, ain .. zer .. ye .. '()', "‘ī%1")
    text = gsub(text, ain .. pesh .. vao .. '()', "‘ū%1")
  
	-- Vao
	text = gsub(text, vao .. '()', "v%1")
	text = gsub(text, '()' .. zabar .. vao .. alif, "%1avā")
	
	-- Fatha Majhool --
	text = gsub(text, "()" .. zabar .. aspirate .. "()" .. "()" .. jazm, "%1hêh%3")
	text = gsub(text, "()" .. zabar .. "()"  .. jazm .. "()" , "%1êh%3")
	text = gsub(text, "()" .. zabar .. "()"  .. jazm , "%1êh")

	-- medial/final consonants.
	text = gsub(text, zabar .. he .. zer .. ye, "ahī")
	text = gsub(text, zabar .. he .. alif, "ahā")
	text = gsub(text, zabar .. he .. '()', "ah%1")
	text = gsub(text, '()' .. alif, "%1ā")
	text = gsub(text, '()' .. tashdid .. alif, "%1%1ā")
	
	text = gsub(text, '()' .. vao, "%1ō")
	text = gsub(text, '()' .. tashdid .. vao, "%1%1ō")
	
	text = gsub(text, zer .. ye .. alif, "iyā")
	text = gsub(text, '()' .. ye .. '()', "%1ē%2")
	text = gsub(text, ye2 .. ye, "ï")
	text = gsub(text, ye2 .. 'ے', "ë")
	text = gsub(text,'()' .. ye .. ye3, "%1ië")
	text = gsub(text, alif .. zabar .. ye3, "ɛ̄")
	text = gsub(text, '()' .. ye2 .. ye, "%1aï")
	text = gsub(text, '()' .. ye2 .. ye3, "%1aë")
	text = gsub(text, zabar .. ye3, "ɛ̄")
	text = gsub(text, '()' .. zer .. " ", "%1-e ")
	
	-- Initial alif
	text = gsub(text, "" .. alif .. '()', "ā%1")
	text = gsub(text, alif .. '()', "a%1")
	text = gsub(text, alif .. zabar .. '()', "a%1")
	text = gsub(text, alif .. zabar .. vao .. '()', "ɔ̄%1")
	text = gsub(text, alif  .. vao .. '()', "ō%1")
	text = gsub(text, alif  .. ye .. '()', "ai%1")
	text = gsub(text, alif .. zabar .. ye .. '()', "ɛ̄%1")
	text = gsub(text, alif .. pesh .. '()', "u%1")
	text = gsub(text, alif .. zer .. '()', "i%1")
	text = gsub(text, pesh .. vao, "ū")
	text = gsub(text, alif .. zer .. ye.. '()', "ī%1")

    -- do-chashme-he zabar, zer, pesh
    text = gsub(text, "()" .. "()" .. aspirate, "%1h%2")
	
	-- diacritics
	text = gsub(text, "()" .. zabar .. vao, "%1ɔ̄")
	text = gsub(text, "()" .. zabar .. ye, "%1ɛ̄")
	text = gsub(text, "()" .. zabar .. ye3, "%1ɛ̄")
	text = gsub(text, "()" .. ye, "%1ī")
	text = gsub(text, "()" .. zer .. ye, "%1ī")
	
	-- final he + short vowel disregards the he and transliterates the vowel
	text = gsub(text, ye .. he , "ye")
	text = gsub(text, "()" .. he , "%1e")
	
	--
	text = gsub(text, zabar .. he .. "()" , "ah%1")
	text = gsub(text, zabar .. he , "a")
	--
	
	text = gsub(text, "ۂ", "a-e")
	text = mw.ustring.gsub(text, 'ahē', "hɛ̄")
	text = mw.ustring.gsub(text, 'ahō', "hɔ̄")
	text = mw.ustring.gsub(text, '.', mapping)

	text = mw.ustring.gsub(text, 'ōā', "vā")
	text = mw.ustring.gsub(text, 'ɔ̄ā', "vā")
	text = mw.ustring.gsub(text, 'ōا', "vā")
	text = mw.ustring.gsub(text, 'ɔ̄aاa', "avā")
	text = mw.ustring.gsub(text, 'ɔ̄ا', "vā")
	text = mw.ustring.gsub(text, 'ɔ̄ا', "vā")
	
	-- Changed these to 'iy(*)', because they will be used for with ی, which are normally written as 'iy'
	text = mw.ustring.gsub(text, 'īā', "iyā")
	text = mw.ustring.gsub(text, 'īa', "iya")
	--
	
	text = mw.ustring.gsub(text, 'aا', "ā")
	text = mw.ustring.gsub(text, 'اē', "ē")
	text = mw.ustring.gsub(text, 'īا', "yā")
	text = mw.ustring.gsub(text, 'yا', "yā")
	text = mw.ustring.gsub(text, 'huō', "hū")
	text = mw.ustring.gsub(text, 'hiē', "hī") 
	text = mw.ustring.gsub(text, 'êha', "êhê")
	
	-- vao as a medial consonant
	text = mw.ustring.gsub(text, "ūa", "uva")
	text = mw.ustring.gsub(text, "ɔ̄()", "av%1")
	--

    -- Final corrections
	text = mw.ustring.gsub(text, "āa", "ā")
	text = mw.ustring.gsub(text, "aaa", "ā")
	text = mw.ustring.gsub(text, "āā", "ā")
	text = mw.ustring.gsub(text, "aa", "ā")
	text = mw.ustring.gsub(text, "ë", "ē")
	text = mw.ustring.gsub(text, "ï", "ī")
	text = mw.ustring.gsub(text, "’alle", "’allāh")
	return text
end
return export