Module:Deva-Tibt-translit
- 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 Devanagari script.
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:Deva-Tibt-translit/testcases.
Functions
edittr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local gsub = mw.ustring.gsub
local export = {}
local conv = {
['क']='ཀ', ['ख']='ཁ', ['ग']='ག', ['घ']='གྷ', ['ङ']='ང',
['च']='ཙ', ['छ']='ཚ', ['ज']='ཛ', ['झ']='ཛྷ', ['ञ']='ཉ',
['ट']='ཊ', ['ठ']='ཋ', ['ड']='ཌ', ['ढ']='ཌྷ', ['ण']='ཎ',
['त']='ཏ', ['थ']='ཐ', ['द']='ད', ['ध']='དྷ', ['न']='ན',
['प']='པ', ['फ']='ཕ', ['ब']='བ', ['भ']='བྷ', ['म']='མ',
['य']='ཡ', ['र']='ར', ['ल']='ལ', ['व']='ཝ', ['श़']='ཞ',
['श']='ཤ', ['ष']='ཥ', ['स']='ས', ['ह']='ཧ', ['स़']='ཟ',
['ा']='ཱ', ['ि']='ི', ['ी']='ཱི', ['ु']='ུ', ['ू']='ཱུ', ['े']='ེ', ['ै']='ཻ', ['ो']='ོ', ['ौ']='ཽ', ['्']='྄', ['ृ']='ྲྀ', ['ॄ']='ྲཱྀ', ['ॢ']='ླྀ', ['ॣ']='ླཱྀ',
-- vowels
['अ']='ཨ', ['आ']='ཨཱ', ['इ']='ཨི', ['ई']='ཨཱི', ['उ']='ཨུ', ['ऊ']='ཨཱུ', ['ए']='ཨེ', ['ऐ']='ཨཻ', ['ओ']='ཨོ', ['औ']='ཨཽ',
['़']='', ['ऋ']='རྀ', ['ॠ']='རཱྀ', ['ऌ']='ལྀ', ['ॡ']='ལཱྀ',
-- chandrabindu
['ँ']='ྃ',
-- anusvara
['ं']='ཾ',
-- visarga
['ः']='ཿ',
-- avagraha
['ऽ']='྅',
-- om
['ॐ']='ༀ',
--punctuation
['॥']='༎',
['।']='།',
['०']='༠', ['१']='༡', ['२']='༢', ['३']='༣', ['४']='༤', ['५']='༥', ['६']='༦', ['७']='༧', ['८']='༨', ['९']='༩',
[' ']='་',
}
function export.tr(text, lang, sc)
text = gsub(
text,
".",
function(c)
return conv[c]
end)
text = gsub(text, 'ས़', "ཟ")
text = gsub(text, 'ཤ़', "ཞ")
text = gsub(text, '྄ཡ', "ྱ")
text = gsub(text, '྄ར', "ྲ")
text = gsub(text, '྄ཝ', "ྭ")
text = gsub(text, '྄ཀ', "ྐ")
text = gsub(text, '྄ཁ', "ྑ")
text = gsub(text, '྄ག', "ྒ")
text = gsub(text, '྄ང', "ྔ")
text = gsub(text, '྄ཅ', "ྕ")
text = gsub(text, '྄ཆ', "ྖ")
text = gsub(text, '྄ཇ', "ྗ")
text = gsub(text, '྄ཉ', "ྙ")
text = gsub(text, '྄ཙ', "ྩ")
text = gsub(text, '྄ཚ', "ྪ")
text = gsub(text, '྄ཛ', "ྫ")
text = gsub(text, '྄ན', "ྣ")
text = gsub(text, '྄ཏ', "ྟ")
text = gsub(text, '྄ཐ', "ྠ")
text = gsub(text, '྄ད', "ྡ")
text = gsub(text, '྄པ', "ྤ")
text = gsub(text, '྄ཕ', "ྥ")
text = gsub(text, '྄བ', "ྦ")
text = gsub(text, '྄མ', "ྨ")
text = gsub(text, '྄ཞ', "ྮ")
text = gsub(text, '྄ཟ', "ྯ")
text = gsub(text, '྄ལ', "ླ")
text = gsub(text, '྄ཤ', "ྴ")
text = gsub(text, '྄ས', "ྶ")
text = gsub(text, '྄ཧ', "ྷ")
text = gsub(text, '྄ཥ', "ྵ")
text = gsub(text, '྄ཊ', "ྚ")
text = gsub(text, '྄ཋ', "ྛ")
text = gsub(text, '྄ཌ', "ྜ")
text = gsub(text, '྄ཎ', "ྞ")
text = gsub(text, 'ཙྱ', "ཅ")
text = gsub(text, 'ཚྱ', "ཆ")
text = gsub(text, 'ཛྱ', "ཇ")
text = gsub(text, 'ཱི', "ི")
text = gsub(text, 'ཱུ', "ུ")
return text
end
return export