Module:txg-translit

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

This module will transliterate Tangut language text. It is also used to transliterate Classical Tibetan. 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:txg-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 LFW2008 = mw.loadData("Module:txg/data/LFW2008")

local meta = {
	 = true,
	 = true,
	 = true
}

local meta_concat = {}
for char in pairs(meta) do
	table.insert(meta_concat, char)
end
meta_concat = require("Module:string utilities").pattern_escape(table.concat(meta_concat))

function export.tr(text, lang, sc)
	local UTF8_char = "*"
	local trtab = {}
	
	local i = 0
	for char in mw.ustring.gmatch(text, ".") do
		i = i + 1
		if meta then
			table.insert(trtab, char)
		elseif char == "𖿠" and i > 1 then
			table.insert(trtab, trtab)
		else
			table.insert(trtab, LFW2008 or "?")
		end
	end
	text = table.concat(trtab, " ")
	
	text = text:gsub(" ?() ?", "%1")
	
	local _, count = mw.ustring.gsub(text, "", "")
	if count == mw.ustring.len(text) then
		return nil
	else
		return "*" .. text
	end
end

return export