Module:inc-ohi-translit

This module will transliterate Old Hindi language text. It is also used to transliterate Old Awadhi. 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:inc-ohi-translit/testcases.

Functions

edit
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 m_str_utils = require("Module:string utilities")
local U = m_str_utils.char
local gsub = m_str_utils.gsub

local export = {}

-- uncommon diacritics
local fatHataan = U(0x64B) -- فَتْحَۃً diacritic
local highhmz = U(0x654) -- ہَمزَہ diacritic
local zwnj = U(0x200C) -- ZWNJ (zero-width non-joiner)
local ghunna = U(0x658) -- نُونِ غُنَّہ diacritic
local dagger_alif = U(0x670) -- اَلِف خَنْجَرِیَّۃ diacritic

-- common diacritics
local zabar = U(0x64E) -- زَبَر diacritic
local zer = U(0x650) -- زیر diacritic
local pesh = U(0x64F) -- پیش diacritic
local tashdid = U(0x651) -- تَشْدِيد, also called شَدَّۃ
local jazm = "ْ" -- diacritic also سُکُون

local tt = {
-- ا
	["آ"] = "ā", -- الِف مَدَّه
	["أ"] = "a", -- اَلِف ہَمزَہ
	["ا"] = "a", -- اَلِف

-- ٮ
	["ب"] = "b", -- بے
	["ٻ"] = "ḇ", -- ٻے (Sindhi/Saraiki implosive)
	["ڀ"] = "bh", -- ڀے (Sindhi aspirate)
	["پ"] = "p", -- پے
	["ت"] = "t", -- تے
	["ٹ"] = "ṭ", -- ٹے (modern retroflex)
	["ٿ"] = "ṭ", -- ٿے (old retroflex)
	["ث"] = "s̱", -- ثے

-- ح
	["ج"] = "j", -- جِيم
	["چ"] = "c", -- چے
	["ڇ"] = "ch", -- ڇے (Sindhi aspirate)
	["ڄ"] = "c", -- ڄے (Sindhi/Saraiki implosive)
	["ڃ"] = "ñ", -- ڃے (Sindhi nasal)
	["ح"] = "ḥ", -- بَڑِی حے
	["خ"] = "x", -- خے

--د
	["د"] = "d", -- دال
	["ݙ"] = "ḏ", -- ݙال (Saraiki implosive)
	["ڈ"] = "ḍ", -- ڈال (modern retroflex)
	["ڐ"] = "ḍ", -- ڐال (old retroflex)
	["ڌ"] = "ḍh", -- ڌال (Sindhi retroflex aspirate)
	["ڏ"] = "ḏ", -- ڏال (Sindhi implosive)
	["ڊ"] = "ḍ", -- ڊال (Sindhi retroflex)
	["ڍ"] = "dh", -- ڍال (Sindhi aspirate)
	["ذ"] = "ẕ", -- ذال

-- ر
	["ر"] = "r", -- رے
	["ڑ"] = "ṛ", -- ڑے (modern retroflex)
	["ڙ"] = "ṛ", -- ڙے (old retroflex)
	["ز"] = "z", -- زے
	["ژ"] = "ž", -- ژے

-- س
	["س"] = "s", -- سِین
	["ش"] = "ś", -- شِین

-- ص
	["ص"] = "ṣ", -- صاد
	["ض"] = "ẓ", -- ضاد

-- ط
	["ط"] = "t̤", -- طوے
	["ظ"] = "z̤", -- ظوے

-- ع ء
	["ع"] = "'", -- عَین
	["ء"] = "'", -- ہَمزَہ
	["غ"] = "ġ", -- غَین

-- ف ق
	["ف"] = "f", -- فے
	["ڦ"] = "ph", -- ڦے (Sindhi aspirate)
	["ق"] = "q", -- قاف

-- ک
	["ک"] = "k", -- کاف
	["ك"] = "k", -- كاف (Arabic variant)
	["ڪ"] = "k", -- ڪاف (Sindhi Kufic variant)
	["گ"] = "g", -- گاف
	["ڳ"] = "g̠", -- ڳاف (Sindhi/Saraiki implosive)
	["ڱ"] = "ṅ", -- ڱاف (Sindhi nasal)

-- ل م
	["لؕ"] = "ḷ", -- اڑلام (Punjabi retroflex)
	["ل"] = "l", -- لام
	["م"] = "m", -- مِیم

-- ں
	["ں"] = "ṉ", -- نُون غُنَّہ
	["ن"] = "n", -- نُون
	["ڻ"] = "ṇ", -- ڻُون (Sindhi retroflex)
	["ݨ"] = "ṇ", -- اڑنون (Punjabi retroflex)

-- و
	["و"] = "v", -- واؤ
	["ؤ"] = "v", -- واوِ مَہْمُوز

-- ہ
	["ہ"] = "h", -- چھوٹِی ہے
	["ه"] = "h", -- چھوٹِی هے (Persian/Arabic variant)
	["ۀ"] = "h", -- ہے یے) بَڑِی یے مَہْمُوز) (in izafat)
	["ة"] = "h", -- تاء مَرْبُوطَة
	["ۃ"] = "h", -- تاء مَرْبُوطَۃ
	["ھ"] = "h", -- دو چَشْمِی ہے

-- ی
	["ی"] = "y", -- یے
	["ى"] = "y", -- اَلِف مَقْصُورَۃ (Arabic)
	["ي"] = "y", -- يے (Arabic variant)
	["ئ"] = "y", -- يے ہَمزَہ
	["ے"] = "e", -- بَڑِی یے
	["ۓ"] = "e", -- بَڑِی یے مَہْمُوز

	-- common diacritics
	[zabar] = "", -- زَبَر diacritic
	[zer] = "", -- زیر diacritic
	[pesh] = "", -- پیش diacritic
	[tashdid] = "", -- تَشْدِيد, also called شَدَّۃ
	[jazm] = "", -- also سُکُون - no vowel

	-- uncommon diacritics
	[zwnj] = "-", -- ZWNJ (zero-width non-joiner)
	[highhmz] = "", -- ہَمزَہ diacritic
	[fatHataan] = "", -- فَتْحَۃً diacritic
	[ghunna] = "", -- نُونِ غُنَّہ diacritic
	[dagger_alif] = "", -- اَلِف خَنْجَرِیَّۃ diacritic

	-- ligatures
	["ﻻ"] = "la",
	["ﷲ"] = "alah",

	-- 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
}

function export.tr(text, lang, sc)
	-- If the script is not ur-Arab, do not transliterate
	if sc ~= "ur-Arab" then
		return
	end
	-- Transliterate characters
	text = gsub(text, '.', tt)
	return text
end
return export