Module:Beng-Deva-translit
Appearance
- 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 Bengali 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:Beng-Deva-translit/testcases.
Functions
[edit]tr(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 = {
-- consonants
['ক']='क', ['খ']='ख', ['গ']='ग', ['ঘ']='घ', ['ঙ']='ङ',
['চ']='च', ['ছ']='छ', ['জ']='ज', ['ঝ']='झ', ['ঞ']='ञ',
['ট']='ट', ['ঠ']='ठ', ['ড']='ड', ['ঢ']='ढ', ['ণ']='ण',
['ত']='त', ['থ']='थ', ['দ']='द', ['ধ']='ध', ['ন']='न',
['প']='प', ['ফ']='फ', ['ব']='ब', ['ভ']='भ', ['ম']='म',
['য']='य', ['র']='र', ['ল']='ल', ['ল়']='ळ', ['শ']='श',
['ষ']='ष', ['স']='स', ['হ']='ह',
['ড়']='ड़', ['ঢ়']='ढ़', ['য়']='य़', ['ৎ']='त्',
-- maatra
['া']='ा', ['ি']='ि', ['ী']='ी', ['ু']='ु', ['ূ']='ू', ['ৃ']='ृ', ['ৄ']='ॄ',
['ৢ']='ॢ', ['ৣ']='ॣ', ['ে']='े', ['ৈ']='ै', ['ো']='ो', ['ৌ']='ौ', ['্']='्', ['়']='़',
-- vowels
['অ']='अ', ['আ']='आ', ['ই']='इ', ['ঈ']='ई', ['উ']='उ', ['ঊ']='ऊ', ['ঋ']='ऋ', ['ৠ']='ॠ',
['ঌ']='ऌ', ['ৡ']='ॡ', ['এ']='ए', ['ঐ']='ऐ', ['ও']='ओ', ['ঔ']='औ',
-- chandrabindu
['ঁ']='ँ',
-- anusvara
['ং']='ं',
-- visarga
['ঃ']='ः',
-- avagraha
['ঽ']='ऽ',
--punctuation
['॥']='॥',
['।']='।',
['ওঁ']='ॐ',
--Vedic extensions
['ᳵ']='ᳵ', ['ᳶ']='ᳶ',
['০']='०', ['১']='१', ['২']='२', ['৩']='३', ['৪']='४', ['৫']='५', ['৬']='६', ['৭']='७', ['৮']='८', ['৯']='९'
}
function export.tr(text, lang, sc, noNuqta)
text = text:gsub("্ব", "्व")
-- Nuqta is not used in Devanagari Sanskrit.
if noNuqta and lang ~= "sa" then
text = text:gsub("ড়", "ড")
:gsub("ঢ়", "ঢ")
:gsub("য়", "য")
end
text = gsub(
text,
".",
function(c)
return conv[c]
end)
return text
end
return export