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.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.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