Module:evn-translit

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

This module will transliterate Evenki language text per WT:EVN TR. 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:evn-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 u = require("Module:string/char")

local MACRON    = u(0x0304)
local DOTABOVE  = u(0x0307)
local DOTBELOW  = u(0x0323)

local str_gsub, ugsub = string.gsub, mw.ustring.gsub
local UTF8char = '*'

local export = {}

local tab = {
	='A', ='a', ='W', ='w', ='E', ='e',
	='Jo', ='jo',	='G', ='g', ='D', ='d',
	='I', ='i',  ='Ī', ='ī', ='J', ='j',
	='K', ='k', ='L', ='l', ='M', ='m',
	='N', ='n', ='Ŋ', ='ŋ', ='O', ='o',
	='P', ='p', ='R', ='r', ='S', ='s', 
	='T', ='t', ='U', ='u', ='Ū', ='ū',
	='F', ='f', ='H', ='h', ='Ç', ='ç',
	='I', ='i', ='Ə', ='ə', ='Ju', ='ju',
	='Ja', ='ja',
	-- non-native letters
	='B', ='b', ='Z', ='z',	='Z', ='z',
	 ='C', ='c',  ='Ş', ='ş',	='Ş', ='ş', --in literary language ш is only found in Russian words and was originally represented with s, however some dialects have ш in native words
	 ='ʺ', ='ʺ', ="’", ="’"
}

local other = {
	{ 'Я', 'Ja' },
	{ 'я', 'ja' },
	{ 'Ё', 'Jo' },
	{ 'ё', 'jo' },
	{ 'Ю', 'Ju' },
	{ 'ю', 'ju' },

-- Unfortunately the Cyrillic alphabet doesn't distinguish between ʒe and ʒə
	{ 'Де', 'Ʒe' },
	{ 'де', 'ʒe' },
	{ 'Не', 'Ņe' },
	{ 'не', 'ņe' },

	{ 'Ди', 'Ʒi' },
	{ 'ди', 'ʒi' },
	{ 'Ни', 'Ņi' },
	{ 'ни', 'ņi' },

	{ 'Дӣ', 'Ʒī' },
	{ 'дӣ', 'ʒī' },
	{ 'Нӣ', 'Ņī' },
	{ 'нӣ', 'ņī' },

	{ 'Дj', 'Ʒ' },
	{ 'дj', 'ʒ' },
	{ 'Нj', 'Ņ' },
	{ 'нj', 'ņ' },
}
 
function export.tr(text, lang, sc)
	for i, replacement in ipairs(other) do
		text = str_gsub(text, unpack(replacement))
	end

    -- е after a vowel or at the beginning of a word becomes ye
    -- Again, the Cyrillic alphabet doesn't distinguish between je and jə
	text = ugsub(text,
		"(?)е",
		"%1je")
    text = ugsub(text,
    	"(?)и",
    	"%1ji")
    text = ugsub(text,
    	"(?)ӣ",
    	"%1jī")
    text = str_gsub(text, "^Е","Je")
    text = str_gsub(text, "^е","je")
    text = ugsub(text, "()Е","%1Je")
    text = ugsub(text, "()е","%1je")
 
    return (str_gsub(text, UTF8char, tab))
end

return export