Module:Olck-translit
- 下列说明文档位于Module:Olck-translit/doc。[编辑]
- 相关链接:子页面列表 • 链入 • 嵌入包含 • 测试用例 • 沙盒
这个模组会将桑塔利文文字转写为拉丁字母。
最好不要直接从模板或其他模组调用此模组。要从模板中使用它,请以{{xlit}}做为替代;若要在模组中使用,则以Module:languages#Language:transliterate替代。
关于测试用例,请参阅Module:Olck-translit/testcases。
函数
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, returnsnil.
local export = {}
local conv = {
['ᱚ']='ô', ['ᱛ']='t', ['ᱜ']='g', ['ᱝ']='ṅ', ['ᱞ']='l',
['ᱟ']='a', ['ᱠ']='k', ['ᱡ']='j', ['ᱢ']='m', ['ᱣ']='v',
['ᱤ']='i', ['ᱥ']='s', ['ᱦ']='h', ['ᱧ']='ñ', ['ᱨ']='r',
['ᱩ']='u', ['ᱪ']='c', ['ᱫ']='d', ['ᱬ']='ṇ', ['ᱭ']='y',
['ᱮ']='e', ['ᱯ']='p', ['ᱰ']='ḍ', ['ᱱ']='n', ['ᱲ']='ṛ',
['ᱳ']='o', ['ᱴ']='ṭ', ['ᱵ']='b', ['ᱶ']='w̃',
['ᱷ']='h', -- aspiration
-- numerals
['᱐']='0', ['᱑']='1', ['᱒']='2', ['᱓']='3', ['᱔']='4', ['᱕']='5', ['᱖']='6', ['᱗']='7', ['᱘']='8', ['᱙']='9',
-- punctuation
['᱿']='.',
['᱾']='.',
-- special chars
['ᱸ']='̃', -- mu tudag: nasalization
['ᱺ']='ᱹ̃', -- mu gahla tudag: nasalization
['ᱻ']='ː' -- rela: gemination
}
local gahla_tudag = {
['ô']='ŏ', ['a']='ă', ['e']='ĕ',
}
local ahad = {
['k’']='g', ['c’']='j', ['t’']='d', ['p’']='b', ['h’']='h'
}
local pharka = {
['g']='k’', ['j']='c’', ['d']='t’', ['b']='p’', ['h']='h’'
}
local punctuation = '([ ᱾᱿,!?"\'])'
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
".",
function(c)
return conv[c]
end)
-- word-final glottalization
text = mw.ustring.gsub(text, '[gjdb]$', pharka)
text = mw.ustring.gsub(
text,
'([gjdb])' .. punctuation,
function(c, d)
return pharka[c] .. d
end)
-- gahla tudag
text = mw.ustring.gsub(
text,
'(.)ᱹ',
function(c)
return gahla_tudag[c]
end
)
-- ahad
text = mw.ustring.gsub(
text,
'(.’)ᱽ',
function(c)
return ahad[c]
end
)
-- parkha
text = mw.ustring.gsub(
text,
'(.)ᱼ',
function(c)
return pharka[c]
end
)
text = mw.ustring.gsub(text, 'h’', 'ʔ')
return text
end
return export
