Module:xchc-translit: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
local tt = { -- Unofficial transliteration loosely based on ISO 9
local tt = { -- Unofficial transliteration loosely based on ISO 9
["І"]='J', ["і"]='j',
["І"]='J', ["і"]='j',
["О" .. B]='Ó', ["о" .. B]='ó', ["О" .. M]='Ō', ["о" .. M]='ō', ["Ō" .. B]='', ["ō" .. B]='', ["О"]='O', ["о"]='o',
["Э"]='E', ["э"]='e', ["Ĕ" .. M]='', ["ĕ" .. M]='', ["Ĕ"]='É', ["ĕ"]='é',
["Э" .. B]='É', ["э" .. B]='é', ["Э" .. M]='Ē', ["э" .. M]='ē', ["Ē" .. B]='', ["Ē" .. B]='ḗ', ["Э"]='E', ["э"]='e',
["О"]='E', ["о"]='e', ["Ŏ" .. M]='', ["ŏ" .. M]='', ["Ŏ"]='Ó', ["ŏ"]='ó',
["Е" .. M .. D]='Jō', ["е" .. M .. D]='jō', ["Ё"]='Jo', ["ё"]='jo',
["Е" .. M .. D]='Jō', ["е" .. M .. D]='jō', ["Ё"]='Jo', ["ё"]='jo',
Line 46: Line 45:
["Я" .. M]='Jā', ["я" .. M]='jā', ["Я"]='Ja', ["я"]='ja',
["Я" .. M]='Jā', ["я" .. M]='jā', ["Я"]='Ja', ["я"]='ja',
["L[ьj]"] = "1", ["l[ьj]"] = "1",
["L[ьj]"] = "Ľ", ["l[ьj]"] = "ľ",
["N[ьj]"]='Ň', ["n[ьj]"]='ň',  
["N[ьj]"]='Ň', ["n[ьj]"]='ň',  
["[ьЬ]"]="'", ["[Ъъ]"]='"',
["[ьЬ]"]="'", ["[Ъъ]"]='"',

Revision as of 15:59, 15 September 2023



local u = mw.ustring.char
local M = u(0x0304)
local B = u(0x0306)
local D = u(0x0308)
local MB = M .. B

local export = {}

local tt = { -- Unofficial transliteration loosely based on ISO 9
	["І"]='J', ["і"]='j',
	["Э"]='E', ["э"]='e', ["Ĕ" .. M]='Ḗ', ["ĕ" .. M]='ḗ', ["Ĕ"]='É', ["ĕ"]='é',
	["О"]='E', ["о"]='e', ["Ŏ" .. M]='Ṓ', ["ŏ" .. M]='ṓ', ["Ŏ"]='Ó', ["ŏ"]='ó',
	
	["Е" .. M .. D]='Jō', ["е" .. M .. D]='jō', ["Ё"]='Jo', ["ё"]='jo',
	["А" .. M]='Ā', ["а" .. M]='ā', ["А"]='A', ["а"]='a',
	["Б"]='B', ["б"]='b',
	["В"]='V', ["в"]='v',
	["Г"]='G', ["г"]='g',
	["Ғ"]='Ǧ', ["ғ"]='ǧ',
	["Д"]='D', ["д"]='d',
	["Е" .. M]='Jē', ["е" .. M]='jē', ["Е"]='Je', ["е"]='je',
	["Ж"]='Ž', ["ж"]='ž',
	["З"]='Z', ["з"]='z', 
	["Ӣ"]='Jī', ["ӣ"]='jī', ["И"]='Ji', ["и"]='ji',
	["К"]='K', ["к"]='k',
	["Л"]='L', ["л"]='l',
	["М"]='M', ["м"]='m',
	["Н"]='N', ["н"]='n',
	["Ӈ"]='Ŋ', ["ӈ"]='ŋ',
	["О" .. M]='Ō', ["о" .. M]='ō', ["О"]='O', ["о"]='o',
	["Ө" .. M]='Ȫ', ["ө" .. M]='ȫ', ["Ө"]='Ö', ["ө"]='ö',
	["П"]='P', ["п"]='p',
	["Р"]='R', ["р"]='r',
	["С"]='S', ["с"]='s',
	["Т"]='T', ["т"]='t',
	["Ӯ"]='Ū', ["ӯ"]='ū', ["У"]='U', ["у"]='u',
	["Ү" .. M]='Ȳ', ["ү" .. M]='ȳ', ["Ү"]='Y', ["ү"]='y',
	["Ф"]='F', ["ф"]='f',
	["ХӀ"]='H', ["хӀ"]='h', ["Х"]='X', ["х"]='x',
	["Ц"]='Ts', ["ц"]='ts',
	["Ч"]='Č', ["ч"]='č',
	["Ш"]='Š', ["ш"]='š',
	["Ы" .. M]='Ī', ["ы" .. M]='ī', ["Ы"]='I', ["ы"]='i',
	["Ю" .. M]='Jū', ["ю" .. M]='jū', ["Ю"]='Ju', ["ю"]='ju',
	["Я" .. M]='Jā', ["я" .. M]='jā', ["Я"]='Ja', ["я"]='ja',
	
	["L[ьj]"] = "Ľ", ["l[ьj]"] = "ľ",
	["N[ьj]"]='Ň', ["n[ьj]"]='ň', 
	["[ьЬ]"]="'", ["[Ъъ]"]='"',
	
	["Й"]='J', ["й"]='j',
};

function export.tr(text, lang, sc)
	for pat, repl in pairs(tt) do
		text = mw.ustring.gsub(text, pat, repl)
	end
	return text
end

return export