Module:Armn-translit

Hello, you have come here looking for the meaning of the word Module:Armn-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Armn-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Armn-translit in singular and plural. Everything you need to know about the word Module:Armn-translit you have here. The definition of the word Module:Armn-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Armn-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate text in the Armenian script per WT:ARMN TR. It is used to transliterate Middle Armenian, Armenian, Northern Kurdish, Kipchak, Lomavren, Udi, and Old Armenian. 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:Armn-translit/testcases.

Functions

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 = {}
local gsub = require("Module:string utilities").gsub

local mapping = {
	="a", ="b", ="g", ="d", ="e", ="z",="ē", ="ə",
	="tʻ", ="ž", ="i", ="l", ="x", ="c", ="k", ="h",
	="j", ="ġ", ="č", ="m", ="y", ="n", ="š", ="o",
	="čʻ", ="p", ="ǰ", ="ṙ", ="s", ="v", ="t", ="r",
	="cʻ", ="w", ="pʻ", ="kʻ", ="ew", ="ō", ="f",
	="A", ="B", ="G", ="D", ="E", ="Z", ="Ē", ="Ə",
	="Tʻ", ="Ž", ="I", ="L", ="X", ="C", ="K", ="H",
	="J", ="Ġ", ="Č", ="M", ="Y", ="N", ="Š", ="O",
	="Čʻ", ="P", ="J̌", ="Ṙ", ="S", ="V", ="T", ="R",
	="Cʻ", ="W", ="Pʻ", ="Kʻ", ="Ō", ="F", ="mn", ="me",
	="mi", ="vn", ="mx", ="ä", ="hª",
	 -- punctuation
	=",", =".", =";", ="́", ="<sup>!</sup>", ="<sup>?</sup>",
	=".", ="-", ="’", ='“', ='”', ='ʻ'
}

local replacements = {
	 -- desirable, but doesn't work:  = 'ʸ',
	 = 'hª', --keep synchronized with ֈ
	 = 'q',
	'] = 'U',
	 = 'u',
	'] = 'Ú',
	 = 'ú',
	'] = 'U<sup>!</sup>',
	 = 'u<sup>!</sup>',
	'] = 'U<sup>?</sup>',
	 = 'u<sup>?</sup>',
	 = 'ü',
	'] = 'Ü',
	 = 'ö',
	 = 'Ö',
}

function export.tr(text, lang, sc)
	if sc and sc ~= "Armn" then
		return nil
	end

	if lang == "xcl" then
		mapping="ł"
		mapping="Ł"
	end

	for regex, replacement in pairs(replacements) do
		text = gsub(text, regex, replacement)
	end

	text = gsub(text, '.', mapping)
	return text
end

return export