Jump to content

Module:User:Suzukaze-c/dng-translit

From Wiktionary, the free dictionary

Huæjzw jyi͡an.

Lohanži sangə nyzʼ

Næhur i͡u jigə lohan li͡an lopər. / Tamu žuali sangə nyzʼ.

Ni zæ bə xi͡o

Ni zæ bə xi͡o, Və bu xin, ni zæ bə hun! / Ni zæ bə sʼ, huli͡užin, vədi ni͡an xin! / Və zæ bu na řə xin huan nidi lʼn xi͡o, / Və čin ni huan ho xinči. Zæ bə zo və!

IPA(key): (Standard Gansu Dungan) /

-xuɛi-tsu- -jүян-.

-lɔ-xæ̃-tɕi- -sæ̃-kə- -ny-tsɿ-

-nɛ-xou- -iou- -ji-kə- -lɔ-xæ̃- -liæ̃- -lɔ-pʰə-. / -tʰa-mou- -tʂua-li- -sæ̃-kə- -ny-tsɿ-.

-ni- -tsɛ- -pə- -ɕiɔ-

-ni- -tsɛ- -pə- -ɕiɔ-, -və- -pou- -ɕiŋ-, -ni- -tsɛ- -pə- -xuŋ-! / -ni- -tsɛ- -pə- -sɿ-, -xou-liou-tɕiŋ-, -və-ti- -niæ̃- -ɕiŋ-! / -və- -tsɛ- -pou- -na- -ʐə- -ɕiŋ- -xuæ̃- -ni-ti- -ləŋ- -ɕiɔ-, / -və- -tɕʰiŋ- -ni- -xuæ̃- -xɔ- -ɕiŋ-tɕʰi-. -tsɛ- -pə- -tsɔ- -və-!

/

Næhur i͡u jigə lodolæ, Tasʼ jigə mʼntulæ, Lodo zæ bazaršon žuan, Ta ba i͡udi za hua kan. / Jigə Balda do mi͡anči͡an, Bu žʼ ta von nani žuan, Ta gi lodo fədi ho: "Visa ni žir či͡ədi zo, Ni zæ žʼtar ba sa zo?"

Bʼj hwti͡ər

Tæjon žošon, bʼj hwti͡ər, / Ni tæ goxin. / Ni li͡an žin guon fadini, / Čidi čun fʼn. / Jisʼr ni do ti͡anšonli, / Zuxi͡on bʼj i͡un. / Jisʼr zu do huajyanli. / Ba xi͡an huar vʼn. / Ži͡ar huardini, və kandi, / Nidi xin go. / Dusʼ nidi da huajyan, / Ni i͡uxir luə. / Ni li͡an hun huar fadini, / Tæi͡onjiban. / Dʼn nidini mo žyhuar. / Xyəbʼj modan... / Nisʼ čunti͡an, guon zodi / Huar kædi von. / Zun luəbudo, hwti͡ər-a, / Žin fui͡əršon.

IPA(key): (Standard Gansu Dungan) /

-nɛ-xou- -iou- -ji-kə- -lɔ-tɔ-lɛ-, -tʰa-sɿ- -ji-kə- -məŋ-tʰou-lɛ-, -lɔ-tɔ- -tsɛ- -pa-tsa-ʂɑŋ- -tʂuæ̃-, -tʰa- -pa- -iou-ti- -tsa- -xua- -kʰæ̃-. / -ji-kə- -pa-ta- -tɔ- -miæ̃-tɕʰiæ̃-, -pou- -tʂʅ- -tʰa- -vɑŋ- -næ̃-i- -tʂuæ̃-, -tʰa- -ki- -lɔ-tɔ- -fə-ti- -xɔ-: "-vi-sa- -ni- -tɕi- -tɕʰiə-ti- -tsɔ-, -ni- -tsɛ- -tʂʅ-tʰa- -pa- -sa- -tsɔ-?"

-pei- -xu-tʰiə-

-tʰэй-ɑŋ- -tʂɔ-ʂɑŋ-, -pei- -xu-tʰiə-, / -ni- -tʰɛ- -kɔ-ɕiŋ-. / -ni- -liæ̃- -tɕiŋ- -kuɑŋ- -fa-tiŋ-i-, / -tɕʰi-ti- -tʂʰuŋ- -fəŋ-. / -ji-sɿ- -ni- -tɔ- -tʰiæ̃-ʂɑŋ-li-, / -tsou-ɕiɑŋ- -pei- -юн-. / -ji-sɿ- -tsou- -tɔ- -xуай-yæ̃-li-. / -pa- -ɕiæ̃- -xua- -vəŋ-. / -tɕia- -xua-tiŋ-i-, -və- -kʰæ̃-ti-, / -ni-ti- -ɕiŋ- -kɔ-. / -tou-sɿ- -ni-ti- -ta- -xуай-yæ̃-, / -ni- -iou-ɕi- -luə-. / -ni- -liæ̃- -xuŋ- -xua- -fa-tiŋ-i-, / -tʰɛ-iɑŋ-ji-pæ̃-. / -təŋ- -ni-tiŋ-i- -mɔ- -tɕy-xua-. / -ɕyə-pei- -mɔ-tæ̃-... / -ni-sɿ- -tʂʰuŋ-tʰiæ̃-, -kuɑŋ- -tsɔ-ti- / -xua- -kʰɛ-ti- -vɑŋ-. / -tsuŋ- -luə-pou-tɔ-, -xu-tʰiə---a-, / -tɕiŋ- -fуе-ʂɑŋ-.

/

Vəmwsʼ minda šoni͡an / Sovi͡ət guonjinšondi, / Zæ kæhuardi gujtwni / li͡an huar jii͡on žonni / (I͡a. Xivaza)

bazaršon; Sovi͡ət Li͡anbon; Tohma

IPA(key): (Standard Gansu Dungan) /

-və-mu-sɿ- -miŋ-ta- -ʂɑŋ-iæ̃- / -sɔ-viə- -kuɑŋ-jiŋ-ʂɑŋ-ti-, / -tsɛ- -kʰɛ-xua-ti- -kuei-tʰўн-i- / -liæ̃- -xua- -ji-iɑŋ- -tʂɑŋ-ni- / (-ia-. -ɕi-va-tsa-)

-pa-tsa-ʂɑŋ-; -sɔ-viə- -liæ̃-pɑŋ-; -tʰɔ-ma-

/

--[[

* https://ru.wikipedia.org/wiki/Дунганская_письменность
* http://www.eki.ee/knab/lat/kbldng.pdf
* 林涛《东干语论稿》
* 林涛《中亚东干语研究》

ا ب پ ت ث
ج چ ح خ د
ذ ر ز ژ س
ش ص ض ڞ ط
ظ ع غ ف ق
ک گ ڴ ل م
ن و ۋ ه ى

]]

local export = {}

local gsub = mw.ustring.gsub
local gmatch = mw.ustring.gmatch
local match = mw.ustring.match

-- Cyrl to Latn, baseless nonsense by yours truly
local tt_custom = {
	['Б'] = 'B', ['П'] = 'P', ['М'] = 'M', ['Ф'] = 'F', ['В'] = 'V',
	['Д'] = 'D', ['Т'] = 'T', ['Н'] = 'N',              ['Л'] = 'L',
	['З'] = 'Z', ['Ц'] = 'C',              ['С'] = 'S',
	['Җ'] = 'Ž', ['Ч'] = 'Č',              ['Ш'] = 'Š', ['Ж'] = 'Ř',
	--[[  ↑  ]]  --[[  ↑  ]]               ['Щ'] = 'X',
	['Г'] = 'G', ['К'] = 'K', ['Ң'] = 'Ŋ', ['Х'] = 'H',
	                                                    ['Р'] = 'R',

	['Ы'] = 'ʼ', ['Й'] = 'J', ['Ў'] = 'W', ['Ү'] = 'Y',
	--[[  ↑  ]]
	['А'] = 'A', ['Я'] = 'I͡a',
	['Ә'] = 'Ə', ['Е'] = 'I͡ə',
	['Э'] = 'Æ',
	['О'] = 'O', ['Ё'] = 'I͡o',
	['У'] = 'U', ['Ю'] = 'I͡u',

	['И'] = 'I',

	['б'] = 'b', ['п'] = 'p', ['м'] = 'm', ['ф'] = 'f', ['в'] = 'v',
	['д'] = 'd', ['т'] = 't', ['н'] = 'n',              ['л'] = 'l',
	['з'] = 'z', ['ц'] = 'c',              ['с'] = 's',
	['җ'] = 'ž', ['ч'] = 'č',              ['ш'] = 'š', ['ж'] = 'ř',
	--[[  ↑  ]]  --[[  ↑  ]]               ['щ'] = 'x',
	['г'] = 'g', ['к'] = 'k', ['ң'] = 'ŋ', ['х'] = 'h',
	                                                    ['р'] = 'r',

	['ы'] = 'ʼ', ['й'] = 'j', ['ў'] = 'w', ['ү'] = 'y',
	--[[  ↑  ]]
	['а'] = 'a', ['я'] = 'i͡a',
	['ә'] = 'ə', ['е'] = 'i͡ə',
	['э'] = 'æ',
	['о'] = 'o', ['ё'] = 'i͡o',
	['у'] = 'u', ['ю'] = 'i͡u',

	['и'] = 'i',
}

-- Cyrl to Latn, modified from the old Dungan Latin alphabet
local tt_classic = {
	['Б'] = 'B', ['П'] = 'P', ['М'] = 'M', ['Ф'] = 'F', ['В'] = 'V',
	['Д'] = 'D', ['Т'] = 'T', ['Н'] = 'N',              ['Л'] = 'L',
	['З'] = 'Z', ['Ц'] = 'C',              ['С'] = 'S',
	['Җ'] = 'Ž', ['Ч'] = 'Č',              ['Ш'] = 'Š', ['Ж'] = 'Ƶ',
	--[[  ↑  ]]  --[[  ↑  ]]               ['Щ'] = 'X',
	['Г'] = 'G', ['К'] = 'K', ['Ң'] = 'Ŋ', ['Х'] = 'H',
	                                                    ['Р'] = 'R',

	['Ы'] = 'Ь', ['Й'] = 'J', ['Ў'] = 'W', ['Ү'] = 'Y',
	--[[  ↑  ]]
	['А'] = 'A', ['Я'] = 'I͡a',
	['Ә'] = 'Ə', ['Е'] = 'I͡ə',
	['Э'] = 'E',
	['О'] = 'O', ['Ё'] = 'I͡o',
	['У'] = 'U', ['Ю'] = 'I͡u',

	['И'] = 'I',

	['б'] = 'b', ['п'] = 'p', ['м'] = 'm', ['ф'] = 'f', ['в'] = 'v',
	['д'] = 'd', ['т'] = 't', ['н'] = 'n',              ['л'] = 'l',
	['з'] = 'z', ['ц'] = 'c',              ['с'] = 's',
	['җ'] = 'ž', ['ч'] = 'č',              ['ш'] = 'š', ['ж'] = 'ƶ',
	--[[  ↑  ]]  --[[  ↑  ]]               ['щ'] = 'x',
	['г'] = 'g', ['к'] = 'k', ['ң'] = 'ŋ', ['х'] = 'h',
	                                                    ['р'] = 'r',

	['ы'] = 'ь', ['й'] = 'j', ['ў'] = 'w', ['ү'] = 'y',
	--[[  ↑  ]]
	['а'] = 'a', ['я'] = 'i͡a',
	['ә'] = 'ə', ['е'] = 'i͡ə',
	['э'] = 'e',
	['о'] = 'o', ['ё'] = 'i͡o',
	['у'] = 'u', ['ю'] = 'i͡u',

	['и'] = 'i',
}

local conv = {}

conv['IPA'] = {
	['intials'] = {
		['б'] = 'p',  ['п'] = 'pʰ',  ['м'] = 'm', ['ф'] = 'f', ['в'] = 'v',
		['д'] = 't',  ['т'] = 'tʰ',  ['н'] = 'n',              ['л'] = 'l',
		['з'] = 'ts', ['ц'] = 'tsʰ',              ['с'] = 's',
		['җ'] = 'tʂ', ['ч'] = 'tʂʰ',              ['ш'] = 'ʂ', ['ж'] = 'ʐ',
		--[[  tɕ  ]]  --[[  tɕʰ  ]]               ['щ'] = 'ɕ',
		['г'] = 'k',  ['к'] = 'kʰ',  ['ң'] = 'ŋ', ['х'] = 'x',
		                                                       ['р'] = 'ɾ',
	
		-- [[ unsure: ]]
		['й'] = 'j',
	},
	['finals'] = {
		[1] = {
			['ы'] = 'ɿ',  ['й'] = 'i',   ['ў'] = 'u', ['ү'] = 'y',
			--[[  ʅ  ]]
			['а'] = 'a',  ['я'] = 'ia',  --[[  ua  ]]
			['ә'] = 'ə',  ['е'] = 'iə',  --[[  uə  ]] --[[  yə  ]]
			['э'] = 'ɛ',                 --[[  uɛ  ]]
			['о'] = 'ɔ',  ['ё'] = 'iɔ',  --[[  uɛi ]]
			--[[  ei  ]]                 --[[  uei ]]
			['у'] = 'ou', ['ю'] = 'iou',
	
			['и'] = 'i',
		},
		[2] = {
			                             ['уа'] = 'ua',
			                             ['уә'] = 'uə', ['үә'] = 'yə',
			                             ['уэ'] = 'uɛ',
			                             --[[  uɛi ]]
			['ый'] = 'ei',               ['уй'] = 'uei',
	
			['ан'] = 'æ̃',  ['ян'] = 'iæ̃',  --[[  uæ̃  ]]   --[[  yæ̃  ]]
			['он'] = 'ɑŋ', ['ён'] = 'iɑŋ', --[[  uɑŋ ]]
			['ын'] = 'əŋ', ['ин'] = 'iŋ',  ['ун'] = 'uŋ', ['үн'] = 'yŋ',
		},
		[3] = {
			                               ['уэй'] = 'uɛi',
	
			                               ['уан'] = 'uæ̃',  ['үан'] = 'yæ̃',
			                               ['уон'] = 'uɑŋ',
		},
	},
	['tones'] = {
		["1"] = "²⁴", ["2"] = "⁵¹", ["3"] = "⁴⁴",
		["0"] = "⁰",
	},
}

conv['foo1'] = {
	['intials'] = {
		['б'] = 'b', ['п'] = 'p', ['м'] = 'm', ['ф'] = 'f', ['в'] = 'v',
		['д'] = 'd', ['т'] = 't', ['н'] = 'n',              ['л'] = 'l',
		['з'] = 'z', ['ц'] = 'c',              ['с'] = 's',
		['җ'] = 'ž', ['ч'] = 'č',              ['ш'] = 'š', ['ж'] = 'ř',
		--[[  ↑  ]]  --[[  ↑  ]]               ['щ'] = 'š',
		['г'] = 'g', ['к'] = 'k', ['ң'] = 'ŋ', ['х'] = 'x',
		                                                    ['р'] = 'r',
	
		-- [[ unsure: ]]
		['й'] = 'j',
	},
	['finals'] = {
		[1] = {
			['ы'] = 'ʼ',  ['й'] = 'i',   ['ў'] = 'uu', ['ү'] = 'y',
			--[[  ʅ  ]]
			['а'] = 'a',  ['я'] = 'ia',  --[[  ua  ]]
			['ә'] = 'o',  ['е'] = 'io',  --[[  uə  ]] --[[  yə  ]]
			['э'] = 'ai',                --[[  uɛ  ]]
			['о'] = 'ao', ['ё'] = 'iao', --[[  uɛi ]]
			--[[  ei  ]]                 --[[  uei ]]
			['у'] = 'u',  ['ю'] = 'iu',
	
			['и'] = 'i',
		},
		[2] = {
			                               ['уа'] = 'ua',
			                               ['уә'] = 'uo', ['үә'] = 'yo',
			                               ['уэ'] = 'uai',
			                               --[[  uɛi ]]
			['ый'] = 'ei',                 ['уй'] = 'uei',
	
			['ан'] = 'an', ['ян'] = 'ian', --[[  uæ̃  ]]   --[[  yæ̃  ]]
			['он'] = 'aŋ', ['ён'] = 'iaŋ', --[[  uɑŋ ]]
			['ын'] = 'en', ['ин'] = 'in',  ['ун'] = 'un', ['үн'] = 'yn',
		},
		[3] = {
			                               ['уэй'] = 'uei',
	
			                               ['уан'] = 'uan', ['үан'] = 'yan',
			                               ['уон'] = 'uaŋ', 
		},
	},
	['tones'] = {
		["1"] = "²⁴", ["2"] = "⁵¹", ["3"] = "⁴⁴",
		["0"] = "⁰",
	},
}

local tt = tt_custom

function export.tr(text, lang, sc)
	if (sc == 'Arab') then
		text = gsub(text, '.', tt_arab)
	end

	text = gsub(text, '([A-Za-z])', '<mark>%1</mark>') -- highlight pre-existing Latn characters
	text = gsub(text, '.', tt)
	text = gsub(text, '([Ѐ-ӿ])', '<mark>%1</mark>') -- highlight remaining Cyrl characters

	return text
end

function export.ipa(text, lang, sc)
	local m_IPA = require('Module:IPA')
	local lang = require('Module:languages').getByCode('dng')
	local conv = conv['IPA']

	local ret = {}

	text = mw.ustring.lower(text)

	local extraA = match(text, '^([^Ё-ёЎўҖҗҢңҮүӘә]*)')
	table.insert(ret, extraA)

	for word, extraB in gmatch(text, '([Ё-ёЎўҖҗҢңҮүӘә]+)([^Ё-ёЎўҖҗҢңҮүӘә]*)') do
		mw.log(word)

		for initial, rime, erhua in gmatch(word, '([бпмфвдтнлзцсҗчшжщгкңхрй]?)([уү]?[ўүыаяәеэоёуюи][йнң]?)(р?)') do
			mw.log('\t', initial, rime, erhua)

			initial = (conv.intials[initial] or '<mark>' .. initial .. '</mark>')
			rime = (conv.finals[mw.ustring.len(rime)][rime] or '<mark>' .. rime .. '</mark>')
			erhua = (erhua ~= '' and '<sub>儿</sub>' or '')

			if (initial == 'tʂ' and match(rime, '^[iy]')) then
				initial = 'tɕ'
			elseif (initial == 'tʂʰ' and match(rime, '^[iy]')) then
				initial = 'tɕʰ'
			elseif (match(initial, '[ʂʐ]') and rime == 'ɿ') then
				rime = 'ʅ'
			end

			-- TODO(? is this a good idea anyway?):
			-- * tones?
			-- * erhua? (is it really just /ɾ/?)
			-- * non-sinitic words?

			table.insert(ret, initial .. rime .. erhua)
		end

		table.insert(ret, extraB)
	end

	text = '/' .. table.concat(ret, '-') .. '/'

	return m_IPA.format_IPA_full { lang = lang, items = {{ pron = text, a = { "Standard Gansu Dungan" } }} }
end

function export.foobar(frame)
	local a = {
		'<table class="wikitable">',
		'<tr>', 
		'<td>' .. export.tr(frame.args[1]) .. '</td>',
		'<td>' .. gsub(export.ipa(frame.args[1]), '<span class="previewonly.+', '') .. '</td>',
		'</tr>',
		'</table>',
	}
	return table.concat(a)
end

return export