Module:API
Ce module regroupe des fonctions liés à l'alphabet phonétique international.
Utilisation
Fonctions exportables :
mapi( frame )– retourne un la liste des symbole API fourni en paramètres, avec lien vers la page correspondant à chaque symbole et si possible un exemple en infobulle.msapi()– retourne entre crochet la fonction mapi.
Autres fonctions :
symbolWithExemple( symbol )– retourne le symbole API avec si possible un exemple en infobulle (span avec title)symbolWithLink( symbol )– retourne le symbole API avec lien vers la page correspondant au symbole et si possible un exemple en infobulle (span avec title)separateSymbols( args )– si args n'a qu'un seul paramètre, sépare les symboles API en autant de paramètre.
Modules externes et autres éléments dont ce module a besoin pour fonctionner :
Module:API/Infobulle– liste des exemples en infobulle.Module:Outils– fonctions extractArgs et trim.
Modèles appelant directement ce module :
Exemples
{{#invoke:API|mapi|m|ɛ|ʁ|s|i| |b|i|ɛ̃}}→ mɛʁsi biɛ̃{{#invoke:API|mapi|mɛʁsi biɛ̃}}→ mɛʁsi biɛ̃{{#invoke:API|msapi|m|ɛ|ʁ|s|i| |b|i|ɛ̃}}→ [mɛʁsi biɛ̃]{{#invoke:API|msapi|mɛʁsi biɛ̃}}→ [mɛʁsi biɛ̃]
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local IPA = { }
local Outils = require ( 'Module:Outils' )
local success, toolTip = pcall ( mw.loadData, 'Module:API/Infobulle' )
-- error if data not loaded
local messageFormat = [[<strong class="error">Le chargement du module API/Infobulle génère une erreur : </strong><br> %s<br>
<span class="error">Cette erreur doit être corrigée pour que les infobulles explicatives soient de nouveau affichées.</span>
]]
local errorMessage
if not success then
errorMessage = string.format( messageFormat, toolTip )
toolTip = { }
end
local ipaClass = ' class="API nowrap"'
local ipaTitle = ' title="Alphabet phonétique international"'
local ipaStyle = ' style="font-family:'
.. "'Segoe UI'," -- Widonws Vista, 7, 8
.. "'DejaVu Sans'," -- Most linux, OpenOffice, LibreOffice
.. "'Lucida Grande'," -- MacOsX
.. "'Lucida Sans Unicode'," -- Windows XP (but lack U+203F & U+035C)
.. "'Arial Unicode MS'," -- MS Office (provides U+203F & U+035C to Windows XP users)
.. "'Hiragino Kaku Gothic Pro'," -- ios 3+
.. "sans-serif" -- default, Android.
.. ';"'
local function symbolWithExemple( symbol )
if type( symbol ) == 'string' then
local title = toolTip[ Outils.trim( symbol ) ]
if title then
return '<span title="' .. title ..'">' .. symbol .. '</span>'
else
return symbol
end
end
end
local function symbolWithLink( symbol )
if symbol == '[' or symbol == ']' then
return mw.text.nowiki( symbol )
elseif symbol ~= '/' and Outils.trim( symbol ) then
return '[[API ' .. symbol .. '|'.. symbolWithExemple( symbol ) .. ']]'
else
return symbol
end
end
local function separateSymbols( args )
local len1 = args[1] and mw.ustring.len( args[1] )
if args[2] == nil and len1 and len1 > 1 then
local api = args[1]
local apiCodes = { mw.ustring.codepoint( args[1], 1, len1 ) }
local result = { }
local i = 1
while apiCodes[i] do
local tmplen = 0
if apiCodes[i + 2] and apiCodes[i + 1] > 859 and apiCodes[i + 1] < 867 then -- tie
tmplen = 2
end
if apiCodes[i + tmplen + 1] and apiCodes[i + tmplen + 1] > 767 and apiCodes[i + tmplen + 1] < 860 then -- Diacritical
tmplen = tmplen + 1
end
table.insert( result, mw.ustring.sub( api, i, i + tmplen ) )
i = i + tmplen + 1
end
return result
end
return args
end
local function symbolsWithLink( args )
local wikiTable = {
'<span' .. ipaClass .. ipaTitle .. ipaStyle .. '>'
}
local symbolsTable = separateSymbols( args )
local i = 1
local symbol
while symbolsTable[i] do
symbol = symbolWithLink( symbolsTable[i] )
if symbol then
table.insert( wikiTable, symbol )
end
i = i + 1
end
table.insert( wikiTable, '</span>' )
return wikiTable
end
function IPA.mapi( frame )
local args = Outils.extractArgs( frame )
local wikiTable = symbolsWithLink( args )
return table.concat( wikiTable )
end
function IPA.msapi ( frame )
local args = Outils.extractArgs( frame )
local wikiTable = symbolsWithLink( args )
if mw.ustring.match(wikiTable[2], '[ʃɲjʄɟ]' ) then
table.insert( wikiTable, 2, ' ' ) --   = Six-Per-Em Space, otherwise ʃ touches [ on windows.
end
if mw.ustring.match(wikiTable[#wikiTable - 1], '[ʃʈɭʄɖɻʠʧ]' ) then
table.insert( wikiTable, #wikiTable, ' ' )
end
if not ( wikiTable[2] == '[' or wikiTable[2] == '/' ) then
table.insert( wikiTable, 2, '[' ) -- [ = <nowiki>[</nowiki>
table.insert( wikiTable, #wikiTable, ']' ) -- ] = <nowiki>]</nowiki>
end
return table.concat( wikiTable )
end
function IPA.api()
end
-- erreurModuleData affiche d'un message d'erreur si le Module:Langue/Data n'a pas été chargé correctement,
-- pour la page de discussion de la base de donnée et ceux qui veulent surveiller cette page.
function IPA.toolTipModuleError()
if success == false then
return errorMessage
end
end
return IPA
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.