Module:Geok-translit

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

This module will transliterate text in the Khutsuri script. It is used to transliterate Georgian and Old Georgian. 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:Geok-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 export = {}
	-- Keep synchronized with [[Module:Geor-translit]] and [[Module:sva-translit]]
local gsub = mw.ustring.gsub
local mapping = {
	 -- Nuskhuri
	["ⴀ"]="a", ["ⴁ"]="b", ["ⴂ"]="g", ["ⴃ"]="d", ["ⴄ"]="e", ["ⴅ"]="v", ["ⴆ"]="z", ["ⴡ"]="ē",
	["ⴇ"]="t", ["ⴈ"]="i", ["ⴉ"]="ḳ", ["ⴊ"]="l", ["ⴋ"]="m", ["ⴌ"]="n", ["ⴢ"]="y", ["ⴍ"]="o",
	["ⴎ"]="ṗ", ["ⴏ"]="ž", ["ⴐ"]="r", ["ⴑ"]="s", ["ⴒ"]="ṭ", ["ⴣ"]="wi", ["ⴓ"]="u", ["ⴔ"]="p",
	["ⴕ"]="k", ["ⴖ"]="ɣ", ["ⴗ"]="q̇", ["ⴘ"]="š", ["ⴙ"]="č", ["ⴚ"]="c",
	["ⴛ"]="ʒ", ["ⴜ"]="c̣", ["ⴝ"]="č̣", ["ⴞ"]="x", ["ⴤ"]="q", ["ⴟ"]="ǯ", ["ⴠ"]="h", ["ⴥ"]="ō", ["ⴧ"]="ə", ["ⴭ"]="ə", 
	 -- Asomtavruli
	["Ⴀ"]="a", ["Ⴁ"]="b", ["Ⴂ"]="g", ["Ⴃ"]="d", ["Ⴄ"]="e", ["Ⴅ"]="v", ["Ⴆ"]="z", ["Ⴡ"]="ē",
	["Ⴇ"]="t", ["Ⴈ"]="i", ["Ⴉ"]="ḳ", ["Ⴊ"]="l", ["Ⴋ"]="m", ["Ⴌ"]="n", ["Ⴢ"]="y", ["Ⴍ"]="o",
	["Ⴎ"]="ṗ", ["Ⴏ"]="ž", ["Ⴐ"]="r", ["Ⴑ"]="s", ["Ⴒ"]="ṭ", ["Ⴣ"]="wi", ["Ⴓ"]="u", ["Ⴔ"]="p",
	["Ⴕ"]="k", ["Ⴖ"]="ɣ", ["Ⴗ"]="q̇", ["Ⴘ"]="š", ["Ⴙ"]="č", ["Ⴚ"]="c",
	["Ⴛ"]="ʒ", ["Ⴜ"]="c̣", ["Ⴝ"]="č̣", ["Ⴞ"]="x", ["Ⴤ"]="q", ["Ⴟ"]="ǯ", ["Ⴠ"]="h", ["Ⴥ"]="ō", ["Ⴧ"]="ə", ["Ⴭ"]="ə", 
}

local replacements = {
	['ႭჃ'] = 'u',
}

function export.tr(text, lang, sc)
	if sc and sc ~= "Geok" then
		return nil
	end
	
	for regex, replacement in pairs(replacements) do
		text = mw.ustring.gsub(text, regex, replacement)
	end
	
	text = gsub(text, '.', mapping)
	return text
end

return export