La documentation pour ce module peut être créée à Module:ar-pronunciation/Documentation
local export = {}
local str_gsub = string.gsub
local ugsub = mw.ustring.gsub
local correspondences = {
= "ʔ",
= "θ",
= "d͡ʒ",
= "ħ",
= "x",
= "ð",
= "ʃ",
= "sˁ",
= "dˁ",
= "tˁ",
= "ðˁ",
= "ʒ",
= "ʕ",
= "ɣ",
= "ɫ",
= "uː",
= "iː",
= "aː",
= "j",
= "ɡ",
= "eː",
= "oː",
= "",
}
local vowels = "aāeēiīoōuū"
local vowel = ""
local long_vowels = "āēīōū"
local long_vowel = ""
local consonant = ""
local syllabify_pattern = "(" .. vowel .. ")(" .. consonant .. "?)(" .. consonant .. "?)(" .. vowel .. ")"
local tie = "‿"
local closed_syllable_shortening_pattern = "(" .. long_vowel .. ")(" .. tie .. ")" .. "(" .. consonant .. ")"
local function syllabify(text)
text = ugsub(text, "%-(" .. consonant .. ")%-(" .. consonant .. ")", "%1.%2")
text = str_gsub(text, "%-", ".")
-- Add syllable breaks.
for _ = 1, 2 do
text = ugsub(
text,
syllabify_pattern,
function(a, b, c, d)
if c == "" and b ~= "" then
c, b = b, ""
end
return a .. b .. "." .. c .. d
end
)
end
-- Add ties between word-final vowels and word-initial consonant clusters.
text = ugsub(
text,
"(" .. vowel .. ") (" .. consonant .. ")%.?(" .. consonant .. ")",
"%1" .. tie .. "%2.%3"
)
return text
end
local function closed_syllable_shortening(text)
local shorten = {
= "a",
= "e",
= "i",
= "o",
= "u",
}
text = ugsub(text,
closed_syllable_shortening_pattern,
function(vowel, tie, consonant)
return shorten .. tie .. consonant
end)
return text
end
function export.link(term)
return "]"
end
function export.toIPA(list, silent_error)
local translit
if list.tr then
translit = list.tr
elseif list.arabic then
-- Returns an error if the word contains alphabetic characters that are not Arabic.
translit = require("Module:ar-translit").tr(list.arabic)
if not translit then
if silent_error then
return ''
else
error('Erreur de translitération pour « ' .. list.arabic .. ' ».')
end
end
else
if silent_error then
return ''
else
error('Aucun texte en arabe ou translitération n’a été fourni à la fonction « toIPA ».')
end
end
translit = str_gsub(translit, "llāh", "ḷḷāh")
translit = ugsub(translit, "( ?)ḷḷ", "%1ll")
-- Remove the transliterations of any tāʾ marbūṭa not marked with a sukūn.
translit = str_gsub(translit, "%(t%)", "")
-- Prodelision after tāʾ marbūṭa
translit = ugsub(translit, "(" .. vowel .. ") " .. vowel, "%1 ")
translit = syllabify(translit)
translit = closed_syllable_shortening(translit)
local output = ugsub(translit, ".", correspondences)
output = str_gsub(output, "%-", "")
return output
end
function export.show(frame)
local params = {
= {},
= {},
}
local args = require("Module:paramètres").process(frame:getParent().args, params)
local arabic = args
local transliteration = args.tr
if not (arabic or transliteration) then
error("Veuillez fournir du texte en arabe ou une transcription.")
end
return export.toIPA { arabic = arabic, tr = transliteration }
end
return export