ข้ามไปเนื้อหา

ผลต่างระหว่างรุ่นของ "มอดูล:blk-translit"

จาก วิกิพจนานุกรม พจนานุกรมเสรี
เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
ไม่มีความย่อการแก้ไข
咽頭べさ (คุย | ส่วนร่วม)
ไม่มีความย่อการแก้ไข
ป้ายระบุ: ถูกย้อนกลับแล้ว
บรรทัดที่ 10: บรรทัดที่ 10:
local tt1 = {
local tt1 = {
-- consonants
-- consonants
['က'] = '', ['ခ'] = '', ['ဂ'] = '', ['ဃ'] = '', ['င'] = '',
['က'] = 'k', ['ခ'] = 'kh', ['ဂ'] = 'g', ['ဃ'] = 'gh', ['င'] = '',
['စ'] = '', ['ဆ'] = '', ['ဇ'] = '', ['ဈ'] = 'ฌ', ['ဉ'] = 'ญ', ['ည'] = '',
['စ'] = 'k', ['ဆ'] = 'ch', ['ဇ'] = 'j', ['ဈ'] = 'jh', ['ည'] = 'ñ',
['ဋ'] = '', ['ဌ'] = '', ['ဍ'] = '', ['ဎ'] = '', [''] = '',
['ဋ'] = '', ['ဌ'] = 'ṭh', ['ဍ'] = '', ['ဎ'] = 'ḍh', [''] = 'ṇ', ["ဏ"] = 'ṇ',
['တ'] = '', ['ထ'] = '', ['ဒ'] = '', ['ဓ'] = '', ['န'] = '',
['တ'] = 't', ['ထ'] = 'th', ['ဒ'] = 'd', ['ဓ'] = 'dh', ['န'] = 'n',
['ပ'] = '', [''] = '', ['ဗ'] = '', ['ဘ'] = '', ['မ'] = '',
['ပ'] = 'p', [''] = 'ph', ['ဗ'] = 'b', ['ဘ'] = 'bh', ['မ'] = 'm',
['ယ'] = '', ['ရ'] = '', ['လ'] = '', ['ဝ'] = '', ['သ'] = '',
['ယ'] = 'y', ['ရ'] = 'r', ['လ'] = 'l', ['ဝ'] = 'w', ['သ'] = 's',
['ဟ'] = '', ['ဠ'] = '', ['အ'] = '',
['ဟ'] = 'h', ['ဠ'] = '', ['အ'] = 'ʼ',
-- independent vowels (1)
-- independent vowels (1)
['ဣ'] = 'อิ', ['ဤ'] = 'อี', ['ဥ'] = 'อุ', ['ဦ'] = 'อู', ['ဩ'] = 'เอา',
['ဣ'] = 'i', ['ဤ'] = 'ī', ['ဥ'] = 'u', ['ဉ'] = 'u', ['ဦ'] = 'ū', ['ဩ'] = 'āo',
-- dependent vowels and diacritics (excluding front type)
-- dependent vowels and diacritics (excluding front type)
['ါ'] = '', ['ာ'] = '', ['ိ'] = '', ['ီ'] = '', ['ု'] = '', ['ူ'] = '',
['ါ'] = 'ā', ['ာ'] = 'ā', ['ိ'] = 'i', ['ီ'] = 'ī', ['ု'] = 'u', ['ူ'] = 'ū', ['ွ'] = 'w', ['ျ'] = 'y',
['ံ'] = '', ['့'] = '̥', ['း'] = ':', ['ႏ'] = '', ['ꩻ'] = '', ['္'] = '', ['်'] = '',
['ံ'] = '', ['့'] = '.', ['း'] = 'ḥ', [''] = '́', ['ႏ'] = '́', ['ꩻ'] = '̀', [''] = '̀', ['္'] = '¡', ['်'] = 'o',
-- numerals
-- numerals
['၀'] = '', ['၁'] = '', ['၂'] = '', ['၃'] = '', ['၄'] = '',
['၀'] = '0', ['၁'] = '1', ['၂'] = '2', ['၃'] = '3', ['၄'] = '4',
[''] = '', [''] = '', [''] = '', [''] = '', [''] = '',
['𑛐'] = '0', ['𑛑'] = '1', ['𑛒'] = '2', ['𑛓'] = '3', ['𑛔'] = '4',
['၅'] = '5', ['၆'] = '6', ['၇'] = '7', ['၈'] = '8', ['၉'] = '9',
-- zero-width space (display it if it hides in a word)
['𑛕'] = '5', ['𑛖'] = '6', ['𑛗'] = '7', ['𑛘'] = '8', ['𑛙'] = '9',
[u(0x200B)] = '‼',
}
}


local adjust1 = {
local adjust1 = {
-- dependent vowels (front type)
-- dependent vowels (front type)
['ေ'] = 'ē', ['ဲ'] = 'ae', ['ော်'] = 'āo', ['ေ့'] = 'e', ['ဲ့'] = 'ea', ['ုဲင့်'] = 'ai', ['ဲုင်'] = 'āi', ['ော့'] = 'ao', ['ို့'] = 'o', ['ို'] = 'ō',
['ေ'] = 'เ%1', ['ဲ'] = 'แ%1',
}
}



รุ่นแก้ไขเมื่อ 18:21, 28 กันยายน 2567

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:blk-translit/testcases.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = '(.['..u(0x0300)..'-'..u(0x036F)..']?)'

local pre = {
	['ျ'] = '္ယ', ['ြ'] = '္ရ', ['ွ'] = '္ဝ', ['ှ'] = '္ဟ',
}

local tt1 = {
	-- consonants
	['က'] = 'k', ['ခ'] = 'kh', ['ဂ'] = 'g', ['ဃ'] = 'gh', ['င'] = 'ṅ',
	['စ'] = 'k', ['ဆ'] = 'ch', ['ဇ'] = 'j', ['ဈ'] = 'jh', ['ည'] = 'ñ',
	['ဋ'] = 'ṭ', ['ဌ'] = 'ṭh', ['ဍ'] = 'ḍ', ['ဎ'] = 'ḍh', ['ၮ'] = 'ṇ', ["ဏ"] = 'ṇ',
	['တ'] = 't', ['ထ'] = 'th', ['ဒ'] = 'd', ['ဓ'] = 'dh', ['န'] = 'n',
	['ပ'] = 'p', ['င'] = 'ph', ['ဗ'] = 'b', ['ဘ'] = 'bh', ['မ'] = 'm',
	['ယ'] = 'y', ['ရ'] = 'r', ['လ'] = 'l', ['ဝ'] = 'w', ['သ'] = 's',
	['ဟ'] = 'h', ['ဠ'] = 'ḷ', ['အ'] = 'ʼ',
	-- independent vowels (1)
	['ဣ'] = 'i', ['ဤ'] = 'ī', ['ဥ'] = 'u', ['ဉ'] = 'u', ['ဦ'] = 'ū', ['ဩ'] = 'āo',
	-- dependent vowels and diacritics (excluding front type)
	['ါ'] = 'ā', ['ာ'] = 'ā', ['ိ'] = 'i', ['ီ'] = 'ī', ['ု'] = 'u', ['ူ'] = 'ū', ['ွ'] = 'w', ['ျ'] = 'y',
	['ံ'] = 'ṁ', ['့'] = '.', ['း'] = 'ḥ', [''] = '́', ['ႏ'] = '́', ['ꩻ'] = '̀', [''] = '̀', ['္'] = '¡', ['်'] = 'o',
	-- numerals
	['၀'] = '0', ['၁'] = '1', ['၂'] = '2', ['၃'] = '3', ['၄'] = '4',
	['𑛐'] = '0', ['𑛑'] = '1', ['𑛒'] = '2', ['𑛓'] = '3', ['𑛔'] = '4',
	['၅'] = '5', ['၆'] = '6', ['၇'] = '7', ['၈'] = '8', ['၉'] = '9',
	['𑛕'] = '5', ['𑛖'] = '6', ['𑛗'] = '7', ['𑛘'] = '8', ['𑛙'] = '9',
}

local adjust1 = {
	-- dependent vowels (front type)
	['ေ'] = 'ē', ['ဲ'] = 'ae', ['ော်'] = 'āo', ['ေ့'] = 'e', ['ဲ့'] = 'ea', ['ုဲင့်'] = 'ai', ['ဲုင်'] = 'āi', ['ော့'] = 'ao', ['ို့'] = 'o', ['ို'] = 'ō', 
}



function export.tr(text, lang, sc, debug_mode)

	if type(text) == 'table' then -- called directly from a template
		text = text.args[1]
	end

	text = gsub(text, '.', pre)

	text = gsub(text, '.', tt1)
	for k, v in pairs(adjust1) do
		text = gsub(text, letter_with_mark..k, v)
	end

	return text
 
end
 
return export