มอดูล:yi-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.
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:yi-translit/testcases.
Functions
[แก้ไข]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 export = {}
local u = mw.ustring.char
local tt = {
['א'] = '', ['אַ'] = 'า', ['אָ'] = '↶โ',
['ב'] = 'บ', ['בֿ'] = 'วฺ',
['ג'] = 'กฺ',
['ד'] = 'ด', ['דזש'] = 'จ',
['ה'] = 'ฮ',
['ו'] = 'ู', ['וּ'] = 'ู', ['וו'] = 'ว', ['װ'] = 'ว', ['וי'] = '↶โย', ['ױ'] = '↶โย',
['ז'] = 'ซฺ', ['זש'] = 'ฌฺ',
['ח'] = 'ค',
['ט'] = 'ต', ['טש'] = 'ช',
['י'] = 'ี', ['יִ'] = 'ี', ['יי'] = '↶เย', ['ײ'] = '↶เย', ['ײַ'] = '↶ไ',
['כּ'] = 'ก', ['כ'] = 'ฅ', ['ך'] = 'ฅ',
['ל'] = 'ล',
['מ'] = 'ม', ['ם'] = 'ม',
['נ'] = 'น', ['ן'] = 'น',
['ס'] = 'ซ',
['ע'] = '↶เ',
['פּ'] = 'ป', ['פֿ'] = 'ฟ', ['ף'] = 'ฟ',
['צ'] = 'ต͡ซ', ['ץ'] = 'ต͡ซ',
['ק'] = 'ก',
['ר'] = 'ร',
['ש'] = 'ฌ', ['שׂ'] = 'ซ',
['תּ'] = 'ต', ['ת'] = 'ซ',
}
function export.tr(text, lang, sc)
if type(text) == 'table' then -- called directly from a template
text = text.args[1]
end
text = mw.ustring.gsub(text, 'דזש', tt)
text = mw.ustring.gsub(text, 'זש', tt)
text = mw.ustring.gsub(text, 'טש', tt)
text = mw.ustring.gsub(text, 'וו', tt)
text = mw.ustring.gsub(text, 'וי', tt)
text = mw.ustring.gsub(text, 'יי', tt)
text = mw.ustring.gsub(text, '.['..u(0x05B7)..u(0x05B8)..u(0x05BC)..u(0x05BF)..u(0x05C2)..']', tt)
text = mw.ustring.gsub(text, '.', tt)
-- fix diphthongs
text = mw.ustring.gsub(text, '([าีูเโไ])([าีู])', '%1อ%2')
text = mw.ustring.gsub(text, '([าีูเโไ])↶([เโไ])', '%1อ↶%2')
text = mw.ustring.gsub(text, '^ี', 'ย')
text = mw.ustring.gsub(text, '([%s%p])ี', '%1ย')
text = mw.ustring.gsub(text, '^ู', 'ว')
text = mw.ustring.gsub(text, '([%s%p])ู', '%1ว')
text = mw.ustring.gsub(text, '(.ฺ?)↶([เโไ])', '%2%1')
return text
end
return export