Module:grc-translit: difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Created page with "--Transliteration for Ancient Greek. local export = {} local tt = { -- Vowels ["[αάὰᾶἀἄἂἆᾰ]"] = "a", ["[ἁἅἃἇ]"] = "ha", ["[ᾱᾳ..." |
fix cases where <h> wrongly appeared mid-diphthong, per Wiktionary:Grease pit/2013/September#Ancient Greek transliteration |
||
Line 68: | Line 68: | ||
local gsub = mw.ustring.gsub |
local gsub = mw.ustring.gsub |
||
⚫ | |||
text = gsub(text, "[ΟΌῸὈὌὊ][ὑὕὓὗὙὝὛὟ]", "Hou") |
|||
text = gsub(text, "γ([γκξχ])", "n%1") |
text = gsub(text, "γ([γκξχ])", "n%1") |
||
Line 79: | Line 76: | ||
text = gsub(text, regex, repl) |
text = gsub(text, regex, repl) |
||
end |
end |
||
⚫ | |||
text = gsub(text, "([AĀEĒIOŌU])h", function (c) |
|||
return "H" .. mw.ustring.lower(c) |
|||
end) |
|||
return text |
return text |
Revision as of 07:44, 7 October 2013
- The following documentation is located at Module:grc-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox (diff)
This module will transliterate Ancient Greek language text per WT:GRC TR. It is also used to transliterate Demotic, Greek, Paeonian, Old Ossetic, Oscan, Dacian, Ancient Macedonian, and Phrygian.
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:grc-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
.
34 of 36 tests failed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
![]() | λόγος | lógos | logos |
![]() | σφίγξ | sphínx | sphinx |
![]() | ϝάναξ | wánax | wanax |
![]() | οἷαι | hoîai | hoiai |
current problems | |||
![]() | ΙΧΘΥΣ | IKHTHUS | IChThUS |
![]() | Υἱός | '''Hu'''iós | '''U'''hios |
u/y | |||
![]() | ταῦρος | taûros | tauros |
![]() | νηῦς | nēûs | nēus |
![]() | σῦς | sûs | sus |
![]() | ὗς | hûs | hus |
![]() | γυῖον | guîon | guion |
![]() | ἀναῡ̈τέω | anaṻtéō | anaṻteō |
![]() | δαΐφρων | daḯphrōn | daïphrōn |
vowel length | |||
![]() | τῶν | tôn | tōn |
![]() | τοὶ | toì | toi |
![]() | τῷ | tôi | tō |
![]() | τούτῳ | toútōi | toutō |
![]() | σοφίᾳ | sophíāi | sophiā |
![]() | μᾱ̆νός | mānós | mā̆nos |
h (rough breathing) | |||
![]() | ὁ | ho | ho |
![]() | οἱ | hoi | hoi |
![]() | εὕρισκε | heúriske | heuriske |
![]() | ὑϊκός | huïkós | huïkos |
![]() | πυρρός | purrhós | purrhos |
![]() | ῥέω | rhéō | rheō |
![]() | σάἁμον | sáhamon | shaamon |
capitals | |||
![]() | Ὀδυσσεύς | Odusseús | Odusseus |
![]() | Εἵλως | Heílōs | Heilōs |
![]() | ᾍδης | Hā́idēs | Hādēs |
![]() | ἡ Ἑλήνη | hē Helḗnē | hē Helēnē |
punctuation | |||
![]() | ἔχεις μοι εἰπεῖν, ὦ Σώκρατες, ἆρα διδακτὸν ἡ ἀρετή; | ékheis moi eipeîn, ô Sṓkrates, âra didaktòn hē aretḗ? | echeis moi eipein, ō Sōkrates, ara didakton hē aretē; |
![]() | τί τηνικάδε ἀφῖξαι, ὦ Κρίτων; ἢ οὐ πρῲ ἔτι ἐστίν; | tí tēnikáde aphîxai, ô Krítōn? ḕ ou prṑi éti estín? | ti tēnikade aphixai, ō Kritōn; ē ou prō eti estin; |
![]() | τούτων φωνήεντα μέν ἐστιν ἑπτά· α ε η ι ο υ ω. | toútōn phōnḗenta mén estin heptá; a e ē i o u ō. | toutōn phōnēenta men estin hepta· a e ē i o u ō. |
![]() | πήγ(νῡμῐ) | pḗg(nūmi) | pēg(nūmi) |
HTML entities | |||
![]() | καλός καὶ ἀγαθός | kalós kaì agathós | kalos kai agathos |
![]() | καλός καὶ ἀγαθός | kalós kaì agathós | kalos kai agathos |
--[[
Transliteration for Ancient Greek.
]]
local export = {}
local tt = {
-- Vowels
["[αάὰᾶἀἄἂἆᾰ]"] = "a",
["[ἁἅἃἇ]"] = "ha",
["[ᾱᾳᾴᾲᾷᾀᾄᾂᾆ]"] = "ā",
["[ᾁᾅᾃᾇ]"] = "hā",
["[εέὲἐἔἒ]"] = "e",
["[ἑἕἓ]"] = "he",
["[ηήὴῆἠἤἢἦῃῄῂῇᾐᾔᾒᾖ]"] = "ē",
["[ἡἥἣἧᾑᾕᾓᾗ]"] = "hē",
["[ιίὶῖἰἴἲἶῐ]"] = "i",
["[ἱἵἳἷ]"] = "hi",
["[ϊΐῒῗ]"] = "ï",
["ῑ"] = "ī",
["[οόὸὀὄὂ]"] = "o",
["[ὁὅὃ]"] = "ho",
["[υύὺῦὐὔὒὖῠ]"] = "u",
["[ὑὕὓὗ]"] = "hu",
["[ϋΰῢῧ]"] = "ü",
["ῡ"] = "ū",
["[ωώὼῶὠὤὢὦῳῴῲῷᾠᾤᾢᾦ]"] = "ō",
["[ὡὥὣὧᾡᾥᾣᾧ]"] = "hō",
["[ΑΆᾺἈἌἊἎᾸ]"] = "A",
["[ἉἍἋἏ]"] = "Ha",
["[Ᾱᾼᾈᾌᾊᾎ]"] = "Ā",
["[ᾉᾍᾋᾏ]"] = "Hā",
["[ΕΈῈἘἜἚ]"] = "E",
["[ἙἝἛ]"] = "He",
["[ΗΉῊἨἬἪἮῌᾘᾜᾚᾞ]"] = "Ē",
["[ἩἭἫἯᾙᾝᾛᾟ]"] = "Hē",
["[ΙΊῚἸἼἺἾῘ]"] = "I",
["[ἹἽἻἿ]"] = "Hi",
["Ϊ"] = "Ï",
["Ῑ"] = "Ī",
["[ΟΌῸὈὌὊ]"] = "O",
["[ὉὍὋ]"] = "Ho",
["[ΥΎῪῨ]"] = "U",
["[ὙὝὛὟ]"] = "Hu",
["Ϋ"] = "Ü",
["Ῡ"] = "Ū",
["[ΩΏῺὨὬὪὮῼᾨᾬᾪᾮ]"] = "Ō",
["[ὩὭὫὯᾩᾭᾫᾯ]"] = "Hō",
-- Consonants
["β"] = "b", ["γ"] = "g", ["δ"] = "d", ["ζ"] = "z", ["θ"] = "th", ["κ"] = "k",
["λ"] = "l", ["μ"] = "m", ["ν"] = "n", ["ξ"] = "x", ["π"] = "p", ["σ"] = "s",
["τ"] = "t", ["φ"] = "ph", ["χ"] = "ch", ["ψ"] = "ps", ["ῥ"] = "rh", ["[ρῤ]"] = "r",
["ς"] = "s",
["Β"] = "B", ["Γ"] = "G", ["Δ"] = "D", ["Ζ"] = "Z", ["Θ"] = "Th", ["Κ"] = "K",
["Λ"] = "L", ["Μ"] = "M", ["Ν"] = "N", ["Ξ"] = "X", ["Π"] = "P", ["Σ"] = "S",
["Τ"] = "T", ["Φ"] = "Ph", ["Χ"] = "Ch", ["Ψ"] = "Ps", ["Ῥ"] = "Rh", ["Ρ"] = "R",
-- Archaic
["ϝ"] = "w", ["ϻ"] = "ś", ["ϙ"] = "q", ["ϡ"] = "š",
["Ϝ"] = "W", ["Ϻ"] = "Ś", ["Ϙ"] = "Q", ["Ϡ"] = "Š",
}
-- Takes a text and return the transliterated form.
function export.tr(text)
if type(text) == 'table' then text = text.args[1] end
local gsub = mw.ustring.gsub
text = gsub(text, "γ([γκξχ])", "n%1")
text = gsub(text, "ρρ", "rrh")
for regex, repl in pairs(tt) do
text = gsub(text, regex, repl)
end
text = gsub(text, "([aāeēioōu])h", "h%1")
text = gsub(text, "([AĀEĒIOŌU])h", function (c)
return "H" .. mw.ustring.lower(c)
end)
return text
end
return export