سٲری اِنسان چھِ آزاد زامٕتؠ۔ وؠقار تہٕ حۆقوٗق چھِ ہِوی۔ تِمَن چھُ سوچ سَمَج عَطا کَرنہٕ آمُت تہٕ تِمَن پَزِ بٲے بَرادٔری ہٕنٛدِس جَذباتَس تَحَت اکھ أکِس اکار بَکار یُن ۔
सऻरी इनसान छि आज़ाद ज़ामॖत्य। व्यक़ार तॖ हॊक़ूक़ छि हिवी। तिमन छु सोच समज अता करनॖ आमुत तॖ तिमन पज़ि बऻय् बरादऺरी हॖन्दिस जज़बातस तहत अख ॳकिस अकार बकार युन ।
local U = mw.ustring.char
local gsub = mw.ustring.gsub
local export = {}
local hri = U(0x93F)
local hri2 = U(0x907)
local diri = U(0x940)
local diri2 = U(0x908)
local hru = U(0x941)
local hru2 = U(0x909)
local diru = U(0x942)
local diru2 = U(0x90A)
local E = U(0x947)
local E2 = U(0x90F)
local AI = U(0x948)
local AI2 = U(0x910)
local O = U(0x94B)
local O2 = U(0x913)
local AU = U(0x94C)
local AU2 = U(0x914)
local A = U(0x905)
local LA = U(0x93E)
local ret = U(0x615)
local halant = U(0x94D)
local zabar = U(0x64E)
local zer = U(0x650)
local pesh = U(0x64F)
local upesh = U(0x657)
local hama = U(0x654)
local hamb = U(0x655)
local hambw = U(0x673)
local kyeh = U(0x620)
local yetail = U(0x6CD)
local smallv = U(0x65A)
local inv = U(0x65B)
local tashdid = U(0x651) -- also called shadda
local jazm = "ْ"
local he = "ہ"
local consonants = "ببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨوہھٹڈںڑشؕ"
local consonantS = "ببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨہھٹڈںڑشؕ"
local consonantS2 = "یببپتثجچحخدذرزژسشصضطظعغفقکگلࣇمنݨںوہھٹڈڑشؕ"
local consonantS3 = "ببپتثیجچحخدذؠرزژسشصضطظعغفقکگلࣇمنݨوہھٹڈںڑشؕ"
local sun = "تثصشسزرذدنلطظض"
local vowels = "اۂۆیؠئےۓوؤٲێ"
local hes = "ہح"
local diacritics = "َُِّْٰ"
local ZZP = "َُِ"
local mapping = {
= 'आ', = 'ब', = 'प',
= 'त', = 'ट', = 'स',
= 'ज', = 'च', = 'ह',
= 'ख़', = 'द', = 'ड',
= 'ज़', = 'र', = "ड़",
= 'ज़', = 'च़', = 'स',
= 'श', = 'स', = 'ज़',
= 'त', = 'ज़', = 'ग़',
= 'फ़', = 'क़', = 'क',
= 'ग', = 'ल', = 'म',
= 'न', = 'व', = 'ह',
= 'य',
= 'ं',
= 'ण', = 'ळ', = 'क',
= 'अ',
= '',
= '',
= 'व',
= 'ऎ',
-- diacritics
= "॑",
= "" .. hri .. "",
= "" .. hru .. "",
= "" .. halant .. "",
= "ऺ",
= "ॖ",
= "ॗ",
= "" .. halant .. "य",
= "" .. halant .. "य",
= "-", -- 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
= "-ये",
= "ॖ"
}
local ain = 'ع'
local kzabar = 'ٰ'
local alif = 'ا'
local halif = 'أ'
local hwalif = 'ٲ'
local madda = 'آ'
local ye = 'ی'
local yev = 'ێ'
local ye2 = 'ئ'
local sualif = 'ٖ'
local ye3 = "ے"
local vao = "و"
local vaov = "ۆ"
local vaor = "ۄ"
local ye4 = "ۓ"
local he2 = "ۂ"
local aspirate = 'ھ'
function export.tr(text, lang, sc)
text = gsub(text, alif .. hambw .. '()', "ॷ%1")
text = gsub(text, alif .. hamb .. '()', "ॶ%1")
text = gsub(text, '()' .. inv, "%1" .. halant .. "")
text = gsub(text, '()' .. '(?)' .. inv, "" .. halant .. "%1%2")
-- EXCEPTIONS - leave as they are, unless they have been sorted out elsewhere
text = gsub(text, '()' .. ye .. "ں", "%1ें")
text = gsub(text, "ؤ" .. pesh, "ऊ")
text = gsub(text, "وہ", "वह")
text = gsub(text, alif .. ye2 .. '(?)' .. '()', "ाय%2")
text = gsub(text, madda .. ye2 .. '(?)' .. '()', "आय%2")
-- SSH
text = gsub(text, "ش" .. jazm .. ret, "ष्")
text = gsub(text, "(ش)" .. "()" .. ret, "ष%2")
-- Tashdeed
text = gsub(text, '()' .. tashdid, "%1" .. halant .. "%1")
text = gsub(text, '()' .. tashdid .. '()', "%1" .. halant .. "%1%2")
text = gsub(text, '()' .. ye .. '()' .. tashdid, "%1य्य%2")
text = gsub(text, '()' .. vao .. '()' .. tashdid, "%1व्व%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" .. halant .. "%1%2")
-- tanween diacritic
text = gsub(text, '()' .. 'ً' .. alif, "%1न")
text = gsub(text, alif .. 'ً', "न")
text = gsub(text, '()' .. 'ً', "%1न")
-- khari zabar --
text = gsub(text, '()' .. kzabar, "%1" .. LA .. "")
text = gsub(text, '()' .. kzabar, "" .. LA .. "")
text = gsub(text, '()' .. tashdid .. alif, "%1" .. halant .. "%1" .. LA .. "")
-- ‘ain
text = gsub(text, '()' .. ain .. zabar .. he, "%1" .. LA .. "")
text = gsub(text, ain .. alif .. ain, "आ")
text = gsub(text, alif .. ain .. '()', "" .. E2 .. "%1")
text = gsub(text, '()' .. ain .. he, "%1अ")
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 .. '()', "इ%1")
text = gsub(text, ain .. pesh .. '()', "उ%1")
text = gsub(text, ain .. zer .. ye .. '()', "ई%1")
text = gsub(text, ain .. vao .. upesh .. '()', "ऊ%1")
text = gsub(text, ain .. jazm, "" .. LA .. "")
-- Vao
text = gsub(text, vao .. '()', "व%1")
text = gsub(text, '()' .. zabar .. vao .. alif, "%1वा")
text = gsub(text, '()' .. zabar .. vao .. zabar .. alif, "%1वा")
text = gsub(text, vao .. vao , "वो")
text = gsub(text, vao .. alif , "वा")
--VAO alone
text = gsub(text, " و ", " ओ ")
-- Fatha Majhool --
text = gsub(text, "()" .. zabar .. he .. jazm .. "()" , "%1ह%2")
text = gsub(text, '()' .. ye3 .. smallv, "%1ॆ")
-- medial/final consonants.
text = gsub(text, he .. '()(?)$', "%1%2")
text = gsub(text, he .. '() ', "%1 ")
text = gsub(text, he .. '() ', "ा ")
text = gsub(text, he .. '()(?)$', "ा%2")
text = gsub(text, zer .. he .. alif , "िहा")
text = gsub(text, zabar .. he .. alif, "हा")
text = gsub(text, zabar .. he .. '()', "ह%1")
text = gsub(text, zer .. he .. '()', "िह%1")
text = gsub(text, '()' .. alif, "%1ा")
text = gsub(text, '()' .. halif, "%1ऺ")
text = gsub(text, '()' .. hwalif, "%1ऻ")
text = gsub(text, '()' .. tashdid .. alif, "%1%1ा")
text = gsub(text, '()' .. tashdid .. vao, "%1%1ो")
text = gsub(text, zer .. ye .. alif, "िया")
text = gsub(text, '()' .. ye .. '()', "%1े%2")
text = gsub(text, '()' .. yev .. '()', "%1ॆ%2")
text = gsub(text, '()' .. ye .. smallv .. '()', "%1ॆ%2")
text = gsub(text, ye2 .. ye, "ई")
text = gsub(text, ye2 .. 'ے', "ए")
text = gsub(text,'()' .. ye .. ye3, "%1" .. diri .. "ए")
text = gsub(text, alif .. zabar .. ye3, "" .. AI2 .. "")
text = gsub(text, '()' .. ye2 .. ye, "%1ई")
text = gsub(text, '()' .. ye2 .. ye3, "%1ए")
text = gsub(text, zabar .. ye3, "ै")
text = gsub(text, '()' .. ye3, "%1" .. E .. "")
text = gsub(text, '()' .. vao .. "(ٗ)", "%1ू")
text = gsub(text, '()' .. vao, "%1" .. O .. "")
text = gsub(text, '()' .. vaov, "%1ॊ")
text = gsub(text, '()' .. vao .. smallv, "%1ॊ")
text = gsub(text, '()' .. vaor .. alif, "%1ौ")
text = gsub(text, '()' .. vaor, "%1ॏ")
text = gsub(text, "()" .. ye .. sualif .. '(?)', "%1" .. diri .. "%2")
text = gsub(text, alif .. ye .. '()', "" .. E2 .. "%1")
text = gsub(text, alif .. yev .. '()', "ऎ%1")
text = gsub(text, alif .. ye .. smallv .. '()', "ऎ%1")
text = gsub(text, alif .. vao .. '()', "" .. O2 .. "%1")
text = gsub(text, pesh .. vao, "ू")
text = gsub(text, "()" .. zer .. ye, "%1" .. diri .. "")
text = gsub(text, alif .. vaov .. '()', "ऒ%1")
text = gsub(text, alif .. vao .. smallv .. '()', "ऒ%1")
-- Initial alif
text = gsub(text, "" .. alif .. '()', "अ%1")
text = gsub(text, "" .. halif .. '()', "ॳ%1")
text = gsub(text, "" .. hwalif .. '()', "ॴ%1")
text = gsub(text, alif .. '()', "अ%1")
text = gsub(text, alif .. zabar .. '()', "अ%1")
text = gsub(text, alif .. vaor .. alif .. '()', "औ%1")
text = gsub(text, alif .. vaor .. '()', "ॵ%1")
text = gsub(text, alif .. vao .. '()', "ओ%1")
text = gsub(text, alif .. ye .. '()', "ए%1")
text = gsub(text, alif .. zabar .. ye .. '()', "ऐ%1")
text = gsub(text, alif .. pesh .. '()', "उ%1")
text = gsub(text, alif .. vao .. upesh .. '()', "" .. diru2 .. "%1")
text = gsub(text, alif .. zer .. '()', "इ%1")
text = gsub(text, alif .. ye .. sualif .. '()', "ई%1")
text = gsub(text, alif .. ye3, "" .. E2 .. "")
--- aspirate
text = gsub(text, "(ک)" .. "()" .. aspirate, "ख%2")
text = gsub(text, "(گ)" .. "()" .. aspirate, "घ%2")
text = gsub(text, "(چ)" .. "()" .. aspirate, "छ%2")
text = gsub(text, "(ج)" .. "()" .. aspirate, "झ%2")
text = gsub(text, "(ٹ)" .. "()" .. aspirate, "ठ%2")
text = gsub(text, "(ڈ)" .. "()" .. aspirate, "ढ%2")
text = gsub(text, "(ت)" .. "()" .. aspirate, "थ%2")
text = gsub(text, "(د)" .. "()" .. aspirate, "ध%2")
text = gsub(text, "(پ)" .. "()" .. aspirate, "फ%2")
text = gsub(text, "(ب)" .. "()" .. aspirate, "भ%2")
text = gsub(text, "(ڑ)" .. "()" .. aspirate, "ढ़%2")
text = gsub(text, "(م)" .. "()" .. aspirate, "म्ह%2")
text = gsub(text, "(ن)" .. "()" .. aspirate, "न्ह%2")
text = gsub(text, "(ل)" .. "()" .. aspirate, "ल्ह%2")
text = gsub(text, "(ژ)" .. "()" .. aspirate, "छ़%2")
-- diacritics
text = gsub(text, "()" .. zabar .. vao, "%1ौ")
text = gsub(text, "()" .. zabar .. ye, "%1ै")
text = gsub(text, "()" .. zabar .. ye3, "%1" .. AI .. "")
text = gsub(text, "()" .. ye, "%1ी")
-- final he + short vowel disregards the he and transliterates the vowel
text = gsub(text, ye .. he , "यह")
text = gsub(text, "()" .. he , "%1ह")
----
text = gsub(text, "نْ()" , "ं%1")
text = gsub(text, "ن٘()" , "ं%1")
text = gsub(text, "مْ()" , "ं%1")
----
text = gsub(text, zabar .. he .. "()" , "ह%1")
text = gsub(text, '()' .. he, "ि")
text = gsub(text, zabar .. he .. alif , "हा")
text = gsub(text, '()' .. he .. alif .. '()' , "%1हा%2")
text = gsub(text, he .. alif , "हा")
--
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 = gsub(text, "ے", "य्")
text = mw.ustring.gsub(text, '.', mapping)
text = mw.ustring.gsub(text, "ललह", "ल्लाह")
text = mw.ustring.gsub(text, 'ोा', "वा")
text = mw.ustring.gsub(text, 'ौा', "वा")
text = mw.ustring.gsub(text, 'ोا', "वा")
text = mw.ustring.gsub(text, 'व॑ا', "वा")
text = mw.ustring.gsub(text, 'ɔ̄ا', "वा")
-- Changed these to 'iy(*)', because they will be used for with ی, which are normally written as 'iy'
text = mw.ustring.gsub(text, 'ी॑ा', "िया")
text = mw.ustring.gsub(text, 'ी॑', "िय")
--
text = mw.ustring.gsub(text, 'اे', "ए")
text = mw.ustring.gsub(text, 'ीا', "िया")
text = mw.ustring.gsub(text, 'यا', "या")
-- vao as a medial consonant
text = mw.ustring.gsub(text, "ूू॑", "ुुव")
text = mw.ustring.gsub(text, "ौ()", "व%1")
-- Final corrections
text = mw.ustring.gsub(text, "अ॑ا", "आ")
text = mw.ustring.gsub(text, "ا", "अ") -- to avoid error
--text = mw.ustring.gsub(text, "हॖ$", "ॖ")
text = mw.ustring.gsub(text, "अٟ", "ॷ")
text = mw.ustring.gsub(text, "ोٗ", "ू")
text = mw.ustring.gsub(text, '॑ि', "इ")
text = mw.ustring.gsub(text, '॑े', "ै")
text = mw.ustring.gsub(text, '॑ो', "ौ")
text = mw.ustring.gsub(text, '्यअ', "्या")
text = mw.ustring.gsub(text, "आ॑", "आ")
text = mw.ustring.gsub(text, "॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑॑", "आ")
text = mw.ustring.gsub(text, '॑', "")
text = mw.ustring.gsub(text, "ीु", "यु")
text = mw.ustring.gsub(text, "ीा", "िया")
text = mw.ustring.gsub(text, "ाि", "ाइ")
text = mw.ustring.gsub(text, "आि", "आइ")
text = mw.ustring.gsub(text, 'ुो', "ू")
text = mw.ustring.gsub(text, 'िे', "ी")
text = mw.ustring.gsub(text, 'ोا', "वा")
text = mw.ustring.gsub(text, 'ौا', "वा")
text = mw.ustring.gsub(text, 'ौा', "वा")
text = mw.ustring.gsub(text, 'ोा', "वा")
text = mw.ustring.gsub(text, 'अै', "ऐ")
text = mw.ustring.gsub(text, 'ीआ', "िया")
text = mw.ustring.gsub(text, 'ीअ', "िय")
text = mw.ustring.gsub(text, '+', "")
text = mw.ustring.gsub(text, 'اिय', "ई")
text = mw.ustring.gsub(text, 'अै', "ऐ")
text = mw.ustring.gsub(text, 'अा', "आ")
text = mw.ustring.gsub(text, 'अौ', "औ")
return text
end
return export