Module:Talu-translit: Difference between revisions
Jump to navigation
Jump to search
m Protected "Module:Talu-translit": (bot) automatically protect highly visible templates/modules (reference score: 2000+ >= 1000) ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) |
m 1 revision imported |
(No difference)
| |
Latest revision as of 12:44, 21 April 2026
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate text in the New Tai Lue script. It is used to transliterate Lü.
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:Talu-translit/testcases.
Functions
tr(text, lang, sc)- Transliterates a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the transliteration fails, returns
nil.
local export = {}
local gsub = mw.ustring.gsub
local tt = {
-- consonants
['ᦀ'] = '˙ʼ', ['ᦁ'] = 'ʼ',
['ᦂ'] = 'k\204\135', ['ᦃ'] = 'x\204\135', ['ᦄ'] = 'n\204\135g', ['ᦅ'] = 'k', ['ᦆ'] = 'x', ['ᦇ'] = 'ng',
['ᦈ'] = 't\204\135s', ['ᦉ'] = 's\204\135', ['ᦊ'] = 'y\204\135', ['ᦋ'] = 'ts', ['ᦌ'] = 's', ['ᦍ'] = 'y',
['ᦎ'] = 't\204\135', ['ᦏ'] = 't\204\135h', ['ᦐ'] = 'n\204\135', ['ᦑ'] = 't', ['ᦒ'] = 'th', ['ᦓ'] = 'n',
['ᦔ'] = 'p\204\135', ['ᦕ'] = 'p\204\135h', ['ᦖ'] = 'm\204\135', ['ᦗ'] = 'p', ['ᦘ'] = 'ph', ['ᦙ'] = 'm',
['ᦚ'] = 'f\204\135', ['ᦛ'] = 'v\204\135', ['ᦜ'] = 'l\204\135', ['ᦝ'] = 'f', ['ᦞ'] = 'v', ['ᦟ'] = 'l',
['ᦠ'] = 'h\204\135', ['ᦡ'] = 'd\204\135', ['ᦢ'] = 'b\204\135', ['ᦣ'] = 'h', ['ᦤ'] = 'd', ['ᦥ'] = 'b',
['ᦦ'] = 'k\204\135w', ['ᦧ'] = 'x\204\135w', ['ᦨ'] = 'kw', ['ᦩ'] = 'xw', ['ᦪ'] = 's\204\135w', ['ᦫ'] = 'sw',
-- vowels and finals (visual ordering by Unicode 8)
['ᦰ'] = '!', ['ᦱ'] = 'aa', ['ᦲ'] = 'ii', ['ᦳ'] = 'u', ['ᦴ'] = 'uu', ['ᦸ'] = 'oa', ['ᦹ'] = 'ue',
['ᦵ'] = 'e', ['ᦶ'] = 'ae', ['ᦷ'] = 'o', ['ᦺ'] = 'ay', -- this line to be swapped
['ᦻ'] = 'aay', ['ᦼ'] = 'uy', ['ᦽ'] = 'oy', ['ᦾ'] = 'oay', ['ᦿ'] = 'uey', ['ᧀ'] = 'iiy',
['ᧁ'] = 'w', ['ᧂ'] = 'ng', ['ᧃ'] = 'n', ['ᧄ'] = 'm', ['ᧅ'] = 'k', ['ᧆ'] = 'd', ['ᧇ'] = 'b',
-- tones
['ᧈ'] = '¹', ['ᧉ'] = '²',
-- numerals
['᧐'] = '0', ['᧑'] = '1', ['᧒'] = '2', ['᧓'] = '3', ['᧔'] = '4',
['᧕'] = '5', ['᧖'] = '6', ['᧗'] = '7', ['᧘'] = '8', ['᧙'] = '9',
['᧚'] = '1',
-- ligatures ᧞ ᧟ sorted after ᦶᦜ
['᧞'] = 'l\204\135ae', ['᧟'] = 'l\204\135aew',
}
function export.tr(text, lang, sc)
if type(text) == 'table' then -- called directly from a template
text = text.args[1]
end
text = gsub(text, '([ᦵᦶᦷᦺ])([ᦀ-ᦫ])', '%2%1') -- swapped
text = gsub(text, '([ᦀ-ᦫ])([ᧁ-ᧇ])', '%1a%2')
text = gsub(text, '.', tt)
text = gsub(text, 'aa!', 'a')
text = gsub(text, 'ii!', 'i')
text = gsub(text, 'uu!', 'u')
text = gsub(text, 'eii', 'oe')
return text
end
return export