Modul:ber-translit

Daripada Wiktionary

Pendokumenan untuk modul ini boleh diciptakan di Modul:ber-translit/doc

local export = {}

local tt = {}

tt["Tfng"] = {
	["common"] = {
		["ⴰ"] = "a",
		["ⴱ"] = "b",
		["ⴲ"] = "ḇ",
		["ⴳ"] = "g",
		["ⴴ"] = "g",
		["ⴵ"] = "ǧ",
		["ⴶ"] = "ǧ",
		["ⴷ"] = "d",
		["ⴸ"] = "ḏ",
		["ⴹ"] = "ḍ",
		["ⴺ"] = "ḏ̣",
		["ⴻ"] = "e",
		["ⴼ"] = "f",
		["ⴽ"] = "k",
		["ⴾ"] = "k",
		["ⴿ"] = "k",
		["ⵀ"] = "h", -- tmh, thv, taq, ttq, thz: "b"
		["ⵁ"] = "h",
		["ⵂ"] = "h",
		["ⵃ"] = "ḥ",
		["ⵄ"] = "ɛ",
		["ⵅ"] = "x",
		["ⵆ"] = "x",
		["ⵇ"] = "q",
		["ⵈ"] = "q",
		["ⵉ"] = "i",
		["ⵊ"] = "j",
		["ⵋ"] = "j",
		["ⵌ"] = "j",
		["ⵍ"] = "l",
		["ⵎ"] = "m",
		["ⵏ"] = "n",
		["ⵐ"] = "ny",
		["ⵑ"] = "ng",
		["ⵒ"] = "p",
		["ⵓ"] = "u", -- tmh, thv, taq, ttq, thz: "w"
		["ⵔ"] = "r",
		["ⵕ"] = "ṛ",
		["ⵖ"] = "ɣ",
		["ⵗ"] = "ɣ",
		["ⵘ"] = "j", -- thz: "ɣ"
		["ⵙ"] = "s",
		["ⵚ"] = "ṣ",
		["ⵜ"] = "t",
		["ⵝ"] = "ṯ",
		["ⵛ"] = "c",
		["ⵞ"] = "č",
		["ⵟ"] = "ṭ",
		["ⵠ"] = "v",
		["ⵡ"] = "w",
		["ⵢ"] = "y",
		["ⵣ"] = "z",
		["ⵤ"] = "z",
		["ⵥ"] = "ẓ",
		["ⵦ"] = "e",
		["ⵧ"] = "o",
		["ⵯ"] = "ʷ",
		["⵰"] = ".",
		["⵿"] = ""
	},
	["tmh"] = {["ⵀ"] = "b", ["ⵓ"] = "w"},
	["thv"] = {["ⵀ"] = "b", ["ⵓ"] = "w"},
	["taq"] = {["ⵀ"] = "b", ["ⵓ"] = "w"},
	["ttq"] = {["ⵀ"] = "b", ["ⵓ"] = "w"},
	["thz"] = {["ⵀ"] = "b", ["ⵓ"] = "w", ["ⵘ"] = "ɣ"}
}

function export.tr(text, lang, sc)
	if not sc then
		sc = require("Module:languages").getByCode(lang or "ber"):findBestScript(text):getCode()
	end

	if sc ~= "Tfng" then
		text = nil
	else
		if tt[sc][lang] then
			text = mw.ustring.gsub(text, '.', tt[sc][lang])
		end
		text = mw.ustring.gsub(text, '.', tt[sc]["common"])
	end

	return text
end

return export