Module:Ougr-translit

From Linguifex
Revision as of 12:45, 21 April 2026 by Sware (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Ougr-translit/doc

local export = {}

local m_str_utils = require("Module:string utilities")

local U = m_str_utils.char

local ougr_combining_dot_above = U(0x10F82)
local ougr_combining_dot_below = U(0x10F83)
local ougr_combining_two_dots_above = U(0x10F84)
local ougr_combining_two_dots_below = U(0x10F85)
local ougr_punctuation_two_dots = U(0x10F88)

local combining_dot_above = U(0x0307)
local combining_dot_below = U(0x0323)
local combining_diaeresis_above = U(0x0308)
local combining_diaeresis_below = U(0x0324)

local tt = {
	["𐽰"] = "ʾ",
	["𐽼"] = "p",
	["𐽽"] = "c",
	["𐽸"] = "d",
	["𐽸𐾂"] = "ḍ",
	["𐾀"] = "t",
	["𐽷"] = "k",
	["𐽲"] = "q",
	["𐽱"] = "β",
	["𐽳"] = "w",
	["𐽴"] = "z",
	["𐽵"] = "x",
	["𐽶"] = "y",
	["𐽹"] = "m",
	["𐽺"] = "n",
	["𐽻"] = "s",
	["𐽾"] = "r",
	["𐽿"] = "š",
	["𐾁"] = "l",
	[ougr_combining_dot_above] = combining_dot_above,
	[ougr_combining_dot_below] = combining_dot_below,
	[ougr_combining_two_dots_above] = combining_diaeresis_above,
	[ougr_combining_two_dots_below] = combining_diaeresis_below,
	[ougr_punctuation_two_dots] = "",
}

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

	if sc ~= "Ougr" then
		text = nil
	else
		text = mw.ustring.gsub(text, '.', tt)
	end

	return text
end

return export