« Module:clé de tri » : différence entre les versions

Contenu supprimé Contenu ajouté
m Annulation des modifications 24178299 de TAKASUGI Shinji : confirmé que � ne marche pas
tables de hachage
Ligne 1 :
local b = require("Module:bases")
local p = {}
 
p.hash = {}
p.hash['eo'] = { ['ĉ'] = 'c⿕', ['ĝ'] = 'g⿕', ['ĥ'] = 'h⿕', ['ĵ'] = 'j⿕', ['ŝ'] = 's⿕', ['ŭ'] = 'u⿕' }
p.hash['es'] = { ['ñ'] = 'n⿕' }
p.hash['fi'] = { ['å'] = 'z⿕', ['ä'] = 'z⿕⿕', ['ö'] = 'z⿕⿕⿕' }
p.hash['os'] = { ['ӕ'] = 'a⿕', ['ё'] = 'e⿕' }
p.hash['sl'] = { ['č'] = 'c⿕', ['š'] = 's⿕', ['ž'] = 'z⿕' }
p.hash['sv'] = p.hash['fi']
p.hash['vi'] = { ['ă'] = 'a⿕', ['ằ'] = 'a⿕', ['ẳ'] = 'a⿕', ['ẵ'] = 'a⿕', ['ắ'] = 'a⿕', ['ặ'] = 'a⿕',
['â'] = 'a⿕⿕', ['ầ'] = 'a⿕⿕', ['ẩ'] = 'a⿕⿕', ['ẫ'] = 'a⿕⿕', ['ấ'] = 'a⿕⿕', ['ậ'] = 'a⿕⿕',
['đ'] = 'd⿕',
['ê'] = 'e⿕', ['ề'] = 'e⿕', ['ể'] = 'e⿕', ['ễ'] = 'e⿕', ['ế'] = 'e⿕', ['ệ'] = 'e⿕',
['ô'] = 'o⿕', ['ồ'] = 'o⿕', ['ổ'] = 'o⿕', ['ỗ'] = 'o⿕', ['ố'] = 'o⿕', ['ộ'] = 'o⿕',
['ơ'] = 'o⿕⿕', ['ờ'] = 'o⿕⿕', ['ở'] = 'o⿕⿕', ['ỡ'] = 'o⿕⿕', ['ớ'] = 'o⿕⿕', ['ợ'] = 'o⿕⿕',
['ư'] = 'u⿕', ['ừ'] = 'u⿕', ['ử'] = 'u⿕', ['ữ'] = 'u⿕', ['ứ'] = 'u⿕', ['ự'] = 'u⿕' }
 
function p.clef(titre, langue)
if titre == nil then return nil end
Ligne 13 ⟶ 28 :
-- Cas particuliers par langue
local hash = if p.hash[langue == 'en' then]
if hash ~= nil then
titre = mw.ustring.gsub(titre, "æ", "ae")
titre = mw.ustring.gsub(titre, "œ%w", "oe"hash)
 
elseif langue == 'eo' then
titre = mw.ustring.gsub(titre, "ĉ", "cx")
titre = mw.ustring.gsub(titre, "ĝ", "gx")
titre = mw.ustring.gsub(titre, "ĥ", "hx")
titre = mw.ustring.gsub(titre, "ĵ", "jx")
titre = mw.ustring.gsub(titre, "ŝ", "sx")
titre = mw.ustring.gsub(titre, "ŭ", "u⿕")
 
elseif langue == 'es' then
titre = mw.ustring.gsub(titre, "ñ", "n⿕")
 
elseif langue == 'fi' or langue == 'sv' then
titre = mw.ustring.gsub(titre, "å", "z⿕")
titre = mw.ustring.gsub(titre, "ä", "z⿕⿕")
titre = mw.ustring.gsub(titre, "ö", "z⿕⿕⿕")
 
elseif langue == 'fr' then
titre = mw.ustring.gsub(titre, "æ", "ae")
titre = mw.ustring.gsub(titre, "œ", "oe")
 
elseif langue == 'os' then
titre = mw.ustring.gsub(titre, "ё", "е⿕")
titre = mw.ustring.gsub(titre, "ӕ", "а⿕")
 
elseif langue == 'sl' then
titre = mw.ustring.gsub(titre, "č", "c⿕")
titre = mw.ustring.gsub(titre, "š", "s⿕")
titre = mw.ustring.gsub(titre, "ž", "z⿕")
 
elseif langue == 'vi' then
titre = mw.ustring.gsub(titre, "ả", "a⿕")
titre = mw.ustring.gsub(titre, "ă", "a⿕")
titre = mw.ustring.gsub(titre, "ắ", "a⿕")
titre = mw.ustring.gsub(titre, "ặ", "a⿕")
titre = mw.ustring.gsub(titre, "ẳ", "a⿕")
titre = mw.ustring.gsub(titre, "ằ", "a⿕")
titre = mw.ustring.gsub(titre, "â", "a⿕⿕")
titre = mw.ustring.gsub(titre, "ầ", "a⿕⿕")
titre = mw.ustring.gsub(titre, "ậ", "a⿕⿕")
titre = mw.ustring.gsub(titre, "ấ", "a⿕⿕")
titre = mw.ustring.gsub(titre, "ẩ", "a⿕⿕")
titre = mw.ustring.gsub(titre, "đ", "d⿕")
titre = mw.ustring.gsub(titre, "ẹ", "e")
titre = mw.ustring.gsub(titre, "ê", "e⿕")
titre = mw.ustring.gsub(titre, "ệ", "e⿕")
titre = mw.ustring.gsub(titre, "ễ", "e⿕")
titre = mw.ustring.gsub(titre, "ề", "e⿕")
titre = mw.ustring.gsub(titre, "ể", "e⿕")
titre = mw.ustring.gsub(titre, "ị", "i")
titre = mw.ustring.gsub(titre, "ì", "i")
titre = mw.ustring.gsub(titre, "í", "i")
titre = mw.ustring.gsub(titre, "ỉ", "i")
titre = mw.ustring.gsub(titre, "î", "i")
titre = mw.ustring.gsub(titre, "ĩ", "i")
titre = mw.ustring.gsub(titre, "ọ", "o")
titre = mw.ustring.gsub(titre, "ỏ", "o")
titre = mw.ustring.gsub(titre, "ô", "o⿕")
titre = mw.ustring.gsub(titre, "ơ", "o⿕⿕")
titre = mw.ustring.gsub(titre, "ộ", "o⿕")
titre = mw.ustring.gsub(titre, "ố", "o⿕")
titre = mw.ustring.gsub(titre, "ồ", "o⿕")
titre = mw.ustring.gsub(titre, "ổ", "o⿕")
titre = mw.ustring.gsub(titre, "ỗ", "o⿕")
titre = mw.ustring.gsub(titre, "ỡ", "o⿕⿕")
titre = mw.ustring.gsub(titre, "ở", "o⿕⿕")
titre = mw.ustring.gsub(titre, "ớ", "o⿕⿕")
titre = mw.ustring.gsub(titre, "ờ", "o⿕⿕")
 
titre = mw.ustring.gsub(titre, "ụ", "u")
titre = mw.ustring.gsub(titre, "ủ", "u")
titre = mw.ustring.gsub(titre, "ư", "u⿕")
titre = mw.ustring.gsub(titre, "ử", "u⿕")
titre = mw.ustring.gsub(titre, "ự", "u⿕")
titre = mw.ustring.gsub(titre, "ừ", "u⿕")
titre = mw.ustring.gsub(titre, "ữ", "u⿕")
 
end
 
Ligne 110 ⟶ 48 :
 
if cle == nil or mw.text.trim(cle) == '' then
return p.clef(titre, langue)
else
return cle
end
end
 
return p
-- Pour tester dans la console :
-- =p.clef('Champs-Élysées', 'fr')