Module:pa-Arab-Mult-convert/sandbox

From Wiktionary, the free dictionary
Jump to navigation Jump to search

local U = mw.ustring.char
local gsub = mw.ustring.gsub
local export = {}

local hri = ''
local hri2 = '𑊁'
local diri = U(0x940)
local diri2 = ''
local hru = ''
local hru2 = '𑊂'
local diru = ''
local diru2 = '𑊂'
local E = ''
local E2 = '𑊃'
local AI = ''
local AI2 = '𑊃'
local O = ''
local O2 = '𑊂'
local AU = ''
local AU2 = '𑊂'
local A = '𑊀'
local LA = ''
local ret = U(0x615)
local halant = U(0x94D)
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 sun = "تثصشسزرذدنلطظض"
local vowels = "ایئےۓوؤ"
local hes = "ہح"
local diacritics = "َُِّْٰ"
local ZZP = "َُِ"
local hiPD = ""

local mapping = {
	["آ"] = '𑊀', ["ب"] = '𑊝', ["پ"] = '𑊛', 
    ["ت"] = '𑊖', ["ٹ"] = '𑊐', ["ث"] = '𑊥',
    ["ج"] = '𑊌', ["چ"] = '𑊊', ["ح"] = '𑊦',
    ["خ"] = '𑊅', ["د"] = '𑊘', ["ڈ"] = '𑊒', 
    ["ذ"] = '𑊌', ["ر"] = '𑊢', ["ڑ"] = "𑊧",
    ["ز"] = '𑊌', ["ژ"] = '𑊥', ["س"] = '𑊥',
    ["ش"] = '𑊥', ["ص"] = '𑊥', ["ض"] = '𑊌',
    ["ط"] = '𑊖', ["ظ"] = '𑊌', ["غ"] = '𑊆',
    ["ف"] = '𑊜', ["ق"] = '𑊄', ["ک"] = '𑊄', 
    ["گ"] = '𑊆', ["ل"] = '𑊣', ["م"] = '𑊠', 
    ["ن"] = '𑊚', ["و"] = '𑊤', ["ہ"] = '𑊦', 
    ["ی"] = '𑊡',
    ["ں"] = '',
	
    ["ڳ"] = '𑊆', ["ݙ"] = '𑊓', ["ڄ"] = '𑊍',

    ["ݨ"] = '𑊕', ["ࣇ"] = '𑊣', ["ك"] = '𑊄',

	["ع"] = '𑊀',
	["ء"] = '',
	["ئ"] = '', 
	["ؤ"] = '𑊂',
	["أ"] = '',
	
	-- diacritics
	[zabar] = "॑",
	[zer] = "" .. hri .. "",
	[pesh] = "" .. hru .. "",
	[jazm] = "", 
	[U(0x200C)] = "-", -- ZWNJ (zero-width non-joiner)
	
	-- ligatures
	["ﻻ"] = "𑊣",
	["ﷲ"] = "𑊀𑊣𑊦",
	
	-- kashida
	["ـ"] = "-", -- kashida, no sound
	

-- numerals
	["١"] = "੧", ["٢"] = "੨", ["٣"] = "੩", ["٤"] = "੪", ["٥"] = "੫", 
	["٦"] = "੬", ["٧"] = "੭", ["٨"] = "੮", ["٩"] = "੯", ["٠"] = "੦",
	["۱"] = "੧", ["۲"] = "੨", ["۳"] = "੩", ["۴"] = "੪", ["۵"] = "੫",
	["۶"] = "੬", ["۷"] = "੭", ["۸"] = "੮", ["۹"] = "੯", ["۰"] = "੦",
	
	-- punctuation (leave on separate lines)
    ["۔"] = "।", 
	["؟"] = "?", -- question mark
	["،"] = ",", -- comma
	["؛"] = ";", -- semicolon
	["«"] = '“', -- quotation mark
	["»"] = '”', -- quotation mark
	["٪"] = "%", -- percent
	["؉"] = "‰", -- per mille
	["٫"] = ".", -- decimals
	["٬"] = ",", -- thousand
    ["ۓ"] = "-𑊃", 
	["ۂ"] = "-𑊃" -- he ye (in ezâfe)
}

local ain = 'ع'
local kzabar = 'ٰ'
local alif = 'ا'
local madda = 'آ'
local ye = 'ی'
local ye2 = 'ئ'
local ye3 = "ے"
local vao = "و"
local ye4 = "ۓ"
local he2 = "ۂ"
local aspirate = 'ھ'
local lam = 'ل'
local noon = 'ن'
local gunDia = '٘'

function export.tr(text, lang, sc)

    text = gsub(text, "ۂ ", "-𑊃-")
    text = gsub(text, "ۓ ", "-𑊃-")
    text = gsub(text, "ࣇ", "𑊣")
    text = gsub(text, "شؕ", "𑊥")
	text = gsub(text, "کھ", "𑊅")
	text = gsub(text, "گھ", "𑊈")
	text = gsub(text, "چھ", "𑊋")
	text = gsub(text, "جھ", "𑊌")
	text = gsub(text, "ٹھ", "𑊐")
	text = gsub(text, "ڈھ", "𑊔")
	text = gsub(text, "تھ", "𑊗")
	text = gsub(text, 'دھ', "𑊙")
	text = gsub(text, "پھ", "𑊜")
	text = gsub(text, "بھ", "𑊟")
    text = gsub(text, "ڑھ", "𑊨")
    text = gsub(text, "مھ", "𑊠𑊦")
	text = gsub(text, "نھ", "𑊚𑊦")
    text = gsub(text, "لھ", "𑊣𑊦")
	text = gsub(text, "بھ", "𑊟")
	text = gsub(text, "ۂ", "-𑊃")
    text = gsub(text, "ے", "")

	text = mw.ustring.gsub(text, '.', mapping)
	

	return text
end
return export