Aller au contenu

Module:Transcript

La bibliothèque libre.

La documentation pour ce module peut être créée à Module:Transcript/Documentation

-- Module : Transcript
-- But : intégration dans le modèle Lang dans un carré flottant au survol du pointeur de la souris. 
-- Fonctions : GreektoLatin et HebrewtoLatin
-- Par Sicarov (compétences limitées en codage) et Challwa.

-- Transcriptions offertes au 14 janvier 2024 : 
--- grec-latin selon la norme ALA-LC (Grec ancien et médieval = texts written before 1454 )(American Library Association – Library of Congress)
--      exemple : {{#invoke:Transcript|GreekToLatin|Αἴτια Ῥωμαϊκά}} ==> Aitia Rhōmaika
--      https://en.wikipedia.org/wiki/Romanization_of_Greek
--- hébreu-latin selon la norme ISO 259-2
--      exemple : {{#invoke:Transcript|HebrewToLatin|דֶּ֫רֶךְ, אָתָה בּוֹא, מִלָּה דָּבָר, חָזָה }} ==> de֫reḵ, ʾatah bwoʾ, milah dabar, ḥazah
--      https://en.wikipedia.org/wiki/ISO_259#ISO_259-2

local p = {};
function p.GreekToLatin(frame)
	local tableGreekToLatinALALC = {
		['Α'] = 'A', ['Ά'] = 'A', ['Ἀ'] = 'A', ['Ἁ'] = 'A', 
		['Ἂ'] = 'A', ['Ἃ'] = 'A', ['Ἄ'] = 'A', ['Ἅ'] = 'A', 
		['Ἆ'] = 'A', ['Ἇ'] = 'A',
		['ᾈ'] = 'A',['ᾉ'] = 'A',
		['ᾊ'] = 'A',['ᾋ'] = 'A',['ᾌ'] = 'A',['ᾍ'] = 'A',
		['ᾎ'] = 'A',['ᾏ'] = 'A',
		['α'] = 'a', ['ά'] = 'a', ['ὰ'] = 'a', ['ἀ'] = 'a', ['ἁ'] = 'a', 
		['ᾶ'] = 'a', ['ᾰ'] = 'a', ['ᾱ'] = 'a',
		['ἂ'] = 'a', ['ἃ'] = 'a', ['ἄ'] = 'a', ['ἅ'] = 'a', 
		['ἆ'] = 'a', ['ἇ'] = 'a',
		['ᾳ'] = 'a', ['ᾀ'] = 'a', ['ᾁ'] = 'a', ['ᾲ'] = 'a',['ᾴ'] = 'a',
		['ᾂ'] = 'a', ['ᾃ'] = 'a', ['ᾄ'] = 'a', ['ᾅ'] = 'a', 
		['ᾷ'] = 'a', ['ᾆ'] = 'a', ['ᾇ'] = 'a',
		['Β'] = 'B', ['β'] = 'b',
		['Γ'] = 'G', ['γ'] = 'g', ['γγ'] = 'ng', ['γξ'] = 'nx', ['γχ'] = 'nch',
		['Δ'] = 'D', ['δ'] = 'd',
		['Ε'] = 'E', ['Έ'] = 'E', ['Ἐ'] = 'E', ['Ἑ'] = 'E', 
		['Ἒ'] = 'E', ['Ἓ'] = 'E', ['Ἔ'] = 'E', ['Ἕ'] = 'E',
		['ε'] = 'e', ['έ'] = 'e', ['ὲ'] = 'e', ['ἐ'] = 'e', ['ἑ'] = 'e', 
		['ἒ'] = 'e', ['ἓ'] = 'e', ['ἔ'] = 'e', ['ἕ'] = 'e',
		['Ζ'] = 'Z', ['ζ'] = 'z',
		['Η'] = 'Ē', ['Ή'] = 'Ē', ['Ἠ'] = 'Ē', ['Ἡ'] = 'Ē', 
		['Ἢ'] = 'Ē', ['Ἣ'] = 'Ē', ['Ἤ'] = 'Ē', ['Ἥ'] = 'Ē', 
		['Ἦ'] = 'Ē', ['Ἧ'] = 'Ē',
		['η'] = 'ē', ['ή'] = 'ē', ['ὴ'] = 'ē', ['ἠ'] = 'ē', ['ἡ'] = 'ē', 
		['ἢ'] = 'ē', ['ἣ'] = 'ē', ['ἤ'] = 'ē', ['ἥ'] = 'ē', 
		['ῆ'] = 'ē', ['ἦ'] = 'ē', ['ἧ'] = 'ē',
        ['ῃ'] = 'ē', ['ᾐ'] = 'ē', ['ᾑ'] = 'ē', ['ῂ'] = 'ē',['ῄ'] = 'ē',
        ['ᾒ'] = 'ē', ['ᾓ'] = 'ē', ['ᾔ'] = 'ē',['ᾕ'] = 'ē', 
        ['ῇ'] = 'ē', ['ᾖ'] = 'ē', ['ᾗ'] = 'ē',
		['Θ'] = 'Th', ['θ'] = 'th',
		['Ι'] = 'I', ['Ί'] = 'I', ['Ἰ'] = 'I', ['Ἱ'] = 'I', 
		['Ἲ'] = 'I', ['Ἳ'] = 'I', ['Ἴ'] = 'I', ['Ἵ'] = 'I', 
		['Ἶ'] = 'I', ['Ἷ'] = 'I',
		['ι'] = 'i', ['ί'] = 'i',['ὶ'] = 'i', ['ἰ'] = 'i', ['ἱ'] = 'i', 
		['ἲ'] = 'i', ['ἳ'] = 'i', ['ἴ'] = 'i', ['ἵ'] = 'i', 
		['ῖ'] = 'i', ['ἶ'] = 'i', ['ἷ'] = 'i',
		['ï'] = 'i', ['ϊ'] = 'i', ['ΐ'] = 'i',  ['ῗ'] = 'i',
		['Κ'] = 'K', ['κ'] = 'k',
		['Λ'] = 'L', ['λ'] = 'l',
		['Μ'] = 'M', ['μ'] = 'm',
		['Ν'] = 'N', ['ν'] = 'n',
		['Ξ'] = 'X', ['ξ'] = 'x',
		['Ο'] = 'O', ['Ό'] = 'O', ['Ὀ'] = 'O', ['Ὁ'] = 'O', ['Ὂ'] = 'O', ['Ὃ'] = 'O', ['Ὄ'] = 'O', ['Ὅ'] = 'O',
		['ο'] = 'o', ['ό'] = 'o', ['ὸ'] = 'o', ['ὀ'] = 'o', ['ὁ'] = 'o', 
		['ὂ'] = 'o', ['ὃ'] = 'o', ['ὄ'] = 'o', ['ὅ'] = 'o',
		['Π'] = 'P', ['π'] = 'p',
		['Ρ'] = 'R', ['Ῥ'] = 'Rh', ['ρ'] = 'r',['ῥ'] = 'rh', ['ῤ'] = 'r',
		['Σ'] = 'S', ['σ'] = 's', ['ς'] = 's',
		['Τ'] = 'T', ['τ'] = 't',
		['Υ'] = 'Y', ['Ύ'] = 'Y',
		['Ὑ'] = 'Y', ['Ὓ'] = 'Y', ['Ὕ'] = 'Y', ['Ὗ'] = 'Y',
		['υ'] = 'u', ['ύ'] = 'u', ['ὺ'] = 'u', ['ὑ'] = 'u', ['ὐ'] = 'u', 
		['ὕ'] = 'u', ['ὓ'] = 'u', ['ὔ'] = 'u', ['ὒ'] = 'u', 
		['ῦ'] = 'u', ['ὖ'] = 'u', ['ὗ'] = 'u',
		['ῠ'] = 'u', ['ῡ'] = 'u',
		['ϋ'] = 'u', ['ΰ'] = 'u', ['ῧ'] = 'u',
		['Φ'] = 'Ph', ['φ'] = 'ph',
		['Χ'] = 'Ch', ['χ'] = 'ch',
		['Ψ'] = 'Ps', ['ψ'] = 'ps',
		['Ω'] = 'Ō', ['Ώ'] = 'Ō', ['Ὠ'] = 'Ō', ['Ὡ'] = 'Ō', ['Ὢ'] = 'Ō', ['Ὣ'] = 'Ō', ['Ὤ'] = 'Ō', ['Ὥ'] = 'Ō', ['Ὦ'] = 'Ō', ['Ὧ'] = 'Ō',
		['ω'] = 'ō', ['ὼ'] = 'ō', ['ώ'] = 'ō', ['ὠ'] = 'ō', ['ὡ'] = 'ō', 
		['ὢ'] = 'ō', ['ὣ'] = 'ō', ['ὤ'] = 'ō', ['ὥ'] = 'ō', 
		['ὦ'] = 'ō', ['ὧ'] = 'ō',
		['ῳ'] = 'ō', ['ᾠ'] = 'ō', ['ᾡ'] = 'ō', 	['ῲ'] = 'ō',['ῴ'] = 'ō',
		['ᾢ'] = 'ō', ['ᾣ'] = 'ō', ['ᾤ'] = 'ō', ['ᾥ'] = 'ō',
		['ῶ'] = 'ō', ['ῷ'] = 'ō', ['ᾦ'] = 'ō', ['ᾧ'] = 'ō',
		['῾'] = 'h',['‘'] = 'h', -- rough breathing
		['᾿'] = '', ['’'] = '',--smooth breathing
		['ͺ'] = '', ['˜'] = '', ['¨'] = '', --iota, circumflex, diaresis

    -- Ajoutez d'autres substitutions au besoin
}
    -- Remplace les lettres grecques par leurs équivalents latins dans le texte fourni 
    local szSubst, n = mw.ustring.gsub(frame.args[1], '[῾᾿‘’ΑΆαάΒβΓγΔδΕΈεέΖζΗΉηήὴΘθΙΊιίὶΚκΛλΜμΝνΞξΟΌοόὸΠπΡρῥΣσςΤτΥΎυύΦφΧχΨψΩΏωώἀἁἂἃἄἅἆἇἈἉἊἋἌἍἎἏἐἑἒἓἔἕἘἙἚἛἜἝἠἡἢἣἤἥἦἧἨἩἪἫἬἭἮἯἰἱϊἲἳἴἵἶἷἸἹἺἻἼἽἾἿὀὁὂὃὄὅὈὉὊὋὌὍὐὑὒὓὔὕὖὗὙὛὝὟὠὡὢὣὤὥὦὧὨὩὪὫὬὭὮὯὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾈᾉᾊᾋᾌᾍᾎᾏᾐᾑᾒᾓᾔᾕᾖᾗᾘᾙᾚᾛᾜᾝᾞᾟᾠᾡᾢᾣᾤᾥᾦᾧᾨᾩᾪᾫᾬᾭᾮᾯᾰᾱᾲᾳᾴᾶᾷᾸᾹᾺΆᾼ᾽ι᾿῀῁ῂῃῄῆῇῈΈῊΉῌ῍῎῏ῐῑῒΐῖῗῘῙῚΊ῝῞῟ῠῡῢΰῤῥῦῧῨῩῪΎῬ῭΅`ῲῳῴῶῷῸΌῺΏῼ´῾]', function(match)
                          return tableGreekToLatinALALC[match] or match
                          end)
    return szSubst
end

function p.HebrewToLatin(frame)
    local tableHebrewToLatinISO_259_2 = {
		['א'] = 'ʾ',
		['ב'] = 'b',
		['בּ'] = 'ḃ',-- ne fonctionne pas
		['ג'] = 'g',
		['ד'] = 'd',
		['ה'] = 'h',
		['הּ'] = 'ḣ',
		['ו'] = 'w',
		['ז'] = 'z',
		['ח'] = 'ḥ',
		['ט'] = 'ṭ',
		['י'] = 'y',
		['כ'] = 'k',
		['ך'] = 'k',
		['כּ'] = 'k̇',
		['ךּ'] = 'k̇',
		['ל'] = 'l',
		['מ'] = 'm',
		['ם'] = 'm',
		['נ'] = 'n',
		['ן'] = 'n',
		['ס'] = 's',
		['ע'] = 'ʿ',
		['פ'] = 'p',
		['ף'] = 'p',
		['פּ'] = 'ṗ',
		['ףּ'] = 'ṗ',
		['צ'] = 'ṣ',
		['ץ'] = 'ṣ',
		['ק'] = 'q',
		['ר'] = 'r',
		['ש'] = 's̀',
		['שׂ'] = 'ś',
		['שׁ'] = 'š',
		['ת'] = 't',
		['׳'] = '‘',
        ['ְ'] = '',
        ['ׁ'] = '', ['ׂ'] = '',
        ['ֱ'] = 'e', -- sh'va
        ['ֶ'] = 'e', -- Segol
        ['ֵ'] = 'e', -- Tsere
        ['ְ'] = '', -- Hatef patah, Hatef qamats, Hatef qamats qatan
        ['ֹ'] = 'o', -- Holam
        ['ֳ'] = 'o', ['ֳ'] = 'o',
        ['ֻ'] = 'u', -- Qubuts
        ['ִ'] = 'i', -- Hiriq
        ['ַ'] = 'a', -- Patah
        ['ָ'] = 'a', ['ָ'] = 'a', -- Qamats
        ['ֲ'] = 'a', ['ֲ'] = 'a',
        ['ּ'] = '', -- Dagesh or Mappiq
        ['ֿ'] = '', -- Rafe
        ['ׄ'] = '', -- Sin/Shin Dot
    }

    -- Remplace les lettres hébraïques par leurs équivalents latins dans le texte fourni 
    local szSubst, n = mw.ustring.gsub(frame.args[1],'[אבגדהוזחטיכךלמםנןסעפףצץקרשתװױײ׳״־–„”‚’◌ְ◌ֱ◌ֲ◌ֳ◌ִ◌ֵ◌ֶ◌ַ◌ָ◌ֹ◌ֻ◌ּ◌ׁ◌ׂ◌ׇ◌֑◌֒◌֓◌֔◌֕◌֖◌֗◌֘◌֙◌֚◌֛◌֜◌֝◌֞◌֟◌֠◌֡◌֢◌֣◌֤◌֥◌֦◌֧◌֨◌֩◌֪◌֫◌֬◌֭◌֮◌֯◌ֿ◌ֽ]', function(match)
                          return tableHebrewToLatinISO_259_2[match] or match
                          end)
    return szSubst
end

return p;