(Translated by https://www.hiragana.jp/)
Modul:grc-translit – Wikiszótár Ugrás a tartalomhoz

Modul:grc-translit

A Wikiszótárból, a nyitott szótárból

Ez a modul ógörög nyelvű szöveg átírására szolgál. Használatos cappadocian greek, paeonian, old ossetic, pontic greek, ancient macedonian és phrygian szöveg átírásához is.

Ezt a modult lehetőleg nem kellene közvetlenül más sablonokból vagy modulokból hívni. Sablonból az {{xlit}}(?) segédsablon, modulból pedig a Module:languages#Language:transliterate metódus használandó.

Függvények

[szerkesztés]
tr(text, lang, sc)
Átírja a text szöveg sc kódú írásrendszerrel írott és lang nyelvű részét. Ha az átírás sikertelen, nilt ad vissza.

1 teszt sikertelen. (frissítés)

Szöveg Várt Tényleges
test_translit:
Sikeres λόγος lógos lógos
Sikeres σφίγξ sphínx sphínx
Sikeres ϝάναξ wánax wánax
Sikeres οおみくろんαあるふぁιいおた hoîai hoîai
u/y
Sikeres τたうαあるふぁῦρος taûros taûros
Sikeres νにゅーηいーたῦς nēûs nēûs
Sikeres σしぐまῦς sûs sûs
Sikeres ὗς hûs hûs
Sikeres γがんまυうぷしろんοおみくろんνにゅー guîon guîon
Sikeres νにゅーαあるふぁῡ̈τέω anaṻtéō anaṻtéō
Sikeres δαΐφρων daḯphrōn daḯphrōn
vowel length
Sikeres τたうνにゅー tôn tôn
Sikeres τたうοおみくろん toì toì
Sikeres τたう tôi tôi
Sikeres τούτῳ toútōi toútōi
Sikeres σοφίᾳ sophíāi sophíāi
Sikeres μみゅーᾱ̆νός mānós mānós
h (rough breathing)
Sikeres ho ho
Sikeres οおみくろん hoi hoi
Sikeres εいぷしろんὕρισκε heúriske heúriske
Sikeres ὑϊκός huïkós huïkós
Sikeres πυρρός purrhós purrhós
Sikeres ῥέω rhéō rhéō
Sikeres σάἁμみゅーοおみくろんνにゅー sáhamon sáhamon
capitals
Sikeres Ὀδυσσεύς Odusseús Odusseús
Sikeres Εいぷしろんἵλως Heílōs Heílōs
Sikeres ᾍδης Hā́idēs Hā́idēs
Sikeres ἡ Ἑλήνη hē Helḗnē hē Helḗnē
Sikertelen 𐠠𐠒𐠯𐠗 pi-lo-ti-mo 𐠠𐠒𐠯𐠗
punctuation
Sikeres ἔχεις μみゅーοおみくろんιいおた εいぷしろんπぱいεいぷしろんνにゅー, ὦ Σώκρατες, ἆρろーαあるふぁ διδακτὸνにゅー ἡ ἀρετή; ékheis moi eipeîn, ô Sṓkrates, âra didaktòn hē aretḗ? ékheis moi eipeîn, ô Sṓkrates, âra didaktòn hē aretḗ?
Sikeres τί τηνικάδε ἀφふぁいξくしーαあるふぁιいおた, ὦ Κρίτων; ἢ οおみくろんπぱいρろーῲ ἔτたうιいおた ἐστίν; tí tēnikáde aphîxai, ô Krítōn? ḕ ou prṑi éti estín? tí tēnikáde aphîxai, ô Krítōn? ḕ ou prṑi éti estín?
Sikeres τούτων φωνήεντα μέν ἐστιν ἑπτά· αあるふぁ εいぷしろん ηいーた ιいおた οおみくろん υうぷしろん ωおめが. toútōn phōnḗenta mén estin heptá; a e ē i o u ō. toútōn phōnḗenta mén estin heptá; a e ē i o u ō.
Sikeres πήγ(νにゅーμみゅーῐ) pḗg(nūmi) pḗg(nūmi)
HTML entities
Sikeres καλός κかっぱαあるふぁὶ ἀγαθός kalós kaì agathós kalós kaì agathós
Sikeres καλός κかっぱαあるふぁὶ ἀγαθός kalós kaì agathós kalós kaì agathós



local export = {}

local m_data = require('Module:grc-utilities/data')
local tokenize = require('Module:grc-utilities').tokenize

local ufind = mw.ustring.find
local ugsub = mw.ustring.gsub
local U = mw.ustring.char
local ulower = mw.ustring.lower
local uupper = mw.ustring.upper

local UTF8char = '[%z\1-\127\194-\244][\128-\191]*'

-- Diacritics
local diacritics = m_data.named

-- Greek
local acute = diacritics.acute
local grave = diacritics.grave
local circumflex = diacritics.circum
local diaeresis = diacritics.diaeresis
local smooth = diacritics.smooth
local rough = diacritics.rough
local macron = diacritics.macron
local breve = diacritics.breve
local subscript = diacritics.subscript

-- Latin
local hat = diacritics.Latin_circum

local macron_diaeresis = macron .. diaeresis .. "?" .. hat
local a_subscript = '^[αあるふぁΑあるふぁ].*' .. subscript .. '$'
local velar = 'κγχξ'

local tt = {
	-- Vowels
	["αあるふぁ"] = "a",
	["εいぷしろん"] = "e",
	["ηいーた"] = "e" .. macron,
	["ιいおた"] = "i",
	["οおみくろん"] = "o",
	["υうぷしろん"] = "u",
	["ωおめが"] = "o" .. macron,

	-- Consonants
	["βべーた"] = "b",
	["γがんま"] = "g",
	["δでるた"] = "d",
	["ζぜーた"] = "z",
	["θしーた"] = "th",
	["κかっぱ"] = "k",
	["λらむだ"] = "l",
	["μみゅー"] = "m",
	["νにゅー"] = "n",
	["ξくしー"] = "x",
	["πぱい"] = "p",
	["ρろー"] = "r",
	["σしぐま"] = "s",
	["ς"] = "s",
	["τたう"] = "t",
	["φふぁい"] = "ph",
	["χかい"] = "kh",
	["ψぷさい"] = "ps",
	
	-- Archaic letters
	["ϝ"] = "w",
	["ϻ"] = "ś",
	["ϙ"] = "q",
	["ϡ"] = "š",
	["ͷ"] = "v",
	
	-- Incorrect characters: see [[Wiktionary:About Ancient Greek#Miscellaneous]].
	-- These are tracked by [[Module:script utilities]].
	["ϐ"] = "b",
	["ϑ"] = "th",
	["ϰ"] = "k",
	["ϱ"] = "r",
	["ϲ"] = "s",
	["ϕ"] = "ph",
	
	-- Diacritics
	-- unchanged: macron, diaeresis, grave, acute
	[breve] = '',
	[smooth] = '',
	[rough] = '',
	[circumflex] = hat,
	[subscript] = 'i',
}

function export.tr(text, lang, sc)
	if text == '῾' then
		return 'h'
	end
	
	--[[
		Replace semicolon or Greek question mark with regular question mark,
		except after an ASCII alphanumeric character (to avoid converting
		semicolons in HTML entities).
	]]
	text = ugsub(text, "([^A-Za-z0-9])[;" .. U(0x37E) .. "]", "%1?")
	
	-- Handle the middle dot. It is equivalent to semicolon or colon, but semicolon is probably more common.
	text = text:gsub("·", ";")
	
	local tokens = tokenize(text)

	--now read the tokens
	local output = {}
	for i, token in pairs(tokens) do
		-- Convert token to lowercase and substitute each character
		-- for its transliteration
		local translit = ulower(token):gsub(UTF8char, tt)
		
		local next_token = tokens[i + 1]
		
		if token == 'γがんま' and next_token and velar:find(next_token, 1, true) then
			-- γがんま before a velar should be <n>
			translit = 'n'
		elseif token == 'ρろー' and tokens[i - 1] == 'ρろー' then
			-- ρろー after ρろー should be <rh>
			translit = 'rh'
		elseif ufind(token, a_subscript) then
			-- add macron to ᾳ
			translit = ugsub(translit, '([aA])', '%1' .. macron)
		end
		
		if token:find(rough) then
			if ufind(token, '^[Ρろーρろー]') then
				translit = translit .. 'h'
			else -- vowel
				translit = 'h' .. translit
			end
		end
		
		-- Remove macron from a vowel that has a circumflex.
		if ufind(translit, macron_diaeresis) then
			translit = translit:gsub(macron, '')
		end
		
		-- Capitalize first character of transliteration.
		if token ~= ulower(token) then
			translit = translit:gsub("^" .. UTF8char, uupper)
		end
		
		table.insert(output, translit)
	end
	output = table.concat(output)
	
	return output
end

return export