Module:AFE
Apparence
La documentation pour ce module peut être créée à Module:AFE/doc
local IPA = { }
local Outils = require ( 'Module:Outils' )
local success, toolTip = pcall ( mw.loadData, 'Module:AFE/Enfobula' )
-- error if data not loaded
local messageFormat = [[<strong class="error">Lo chargement du modulo AFE/Enfobula fât na fôta : </strong><br> %s<br>
<span class="error">Cela fôta dêt étre corregiêe por que les enfobules èxplicatives seyont tornâyes montrar.</span>
]]
local errorMessage
if not success then
errorMessage = string.format( messageFormat, toolTip )
toolTip = { }
end
local ipaClass = ' class="AFE"'
local ipaTitle = ' title="Alfabèt fonètico entèrnacionâl"'
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 '[[AFE ' .. 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 afe = args[1]
local afeCodes = { mw.ustring.codepoint( args[1], 1, len1 ) }
local result = { }
local i = 1
while afeCodes[i] do
local tmplen = 0
if afeCodes[i + 2] and afeCodes[i + 1] > 859 and afeCodes[i + 1] < 867 then -- tie
tmplen = 2
end
if afeCodes[i + tmplen + 1] and afeCodes[i + tmplen + 1] > 767 and afeCodes[i + tmplen + 1] < 860 then -- Diacritical
tmplen = tmplen + 1
end
table.insert( result, mw.ustring.sub( afe, 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.mafe( frame )
local args = Outils.extractArgs( frame )
local wikiTable = symbolsWithLink( args )
return table.concat( wikiTable )
end
function IPA.msafe ( frame )
local args = Outils.extractArgs( frame )
local wikiTable = symbolsWithLink( args )
if wikiTable[2]:match( '[ʃɲjʄɟ]' ) then
table.insert( wikiTable, 2, ' ' ) --   = Six-Per-Em Space, otherwise ʃ touches [ on windows.
end
if wikiTable[#wikiTable - 1]:match( '[ʃʈɭʄɖɻʠʧ]' ) 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.afe()
end
-- fôtaModuloData pancârta d’un mèssâjo de fôta se lo Modulo:Lengoua/Data est pas étâ chargiê coment fôt,
-- por la pâge de discussion de la bâsa de balyês et celos que vôlont gouardar cela pâge.
function IPA.toolTipModuleError()
if success == false then
return errorMessage
end
end
return IPA