Modifications

642 octets ajoutés ,  20 janvier 2023 à 01:35
aucun résumé de modification
Ligne 5 : Ligne 5 :  
function p.ts(frame)
 
function p.ts(frame)
 
     local villagerlist = frame.args[1]
 
     local villagerlist = frame.args[1]
    local villagertable = {}
      
     if villagerlist ~= nil then
 
     if villagerlist ~= nil then
         local values = mw.text.split(villagerlist, ",", true)
+
         for i = 1, #values do
+
local vtable = {}
             local v = mw.text.trim(values[i])
+
         local villagers = mw.text.split(villagerlist, ",", true)
 +
         for i = 1, #villagers do
 +
             local v = mw.text.trim(villagers[i])
 
             if v ~= "" then
 
             if v ~= "" then
                 table.insert(villagertable, v)
+
                 table.insert(vtable, v)
 
             end
 
             end
 
         end
 
         end
 +
 +
--remove duplicate entries
 +
local dupes = {}
 +
local villagertable = {}
 +
for i = 1, #vtable do
 +
  if not dupes[vtable[i]] then
 +
  table.insert(villagertable, vtable[i])
 +
  dupes[vtable[i]] = true
 +
  end
 +
end
 
 
 
--sort in English for JA & ZH, as the old template did
 
--sort in English for JA & ZH, as the old template did
Ligne 34 : Ligne 45 :  
if v == "Wizard" then villagertable[k] = "Sorcier" end
 
if v == "Wizard" then villagertable[k] = "Sorcier" end
 
if v == "Robin" then villagertable[k] = "Robine" end
 
if v == "Robin" then villagertable[k] = "Robine" end
if v == "Leo" then villagertable[k] = "Léo" end
+
--In order to sort entries added as Léo, we have to
 +
--convert to English, then sort, then convert back.
 +
if v == "Léo" then villagertable[k] = "Leo" end
 +
--skip Léo until after the language-specific sort
 
end
 
end
 
elseif lang == "IT" then
 
elseif lang == "IT" then
Ligne 211 : Ligne 225 :     
--put the table "villagertable" back into a string blob
 
--put the table "villagertable" back into a string blob
 +
--table.concat( table, sep, i, j ) DOES NOT WORK
 
villagerlist = ""
 
villagerlist = ""
for i=1, (#villagertable-1) do
+
for i = 1, (#villagertable-1) do
 
villagerlist = villagerlist .. '<span class="no-wrap">[[File:' .. villagertable[i] .. ' Icon.png|32px|link=' .. villagertable[i] .. ']]&nbsp;[[' .. villagertable[i] .. ']]</span> • '
 
villagerlist = villagerlist .. '<span class="no-wrap">[[File:' .. villagertable[i] .. ' Icon.png|32px|link=' .. villagertable[i] .. ']]&nbsp;[[' .. villagertable[i] .. ']]</span> • '
 
end
 
end
Ligne 221 : Ligne 236 :  
--Now that we've sorted by the native language,  
 
--Now that we've sorted by the native language,  
 
--fix icons whose names are all in English
 
--fix icons whose names are all in English
 +
--Also add the é to Leo for French
 +
--so I don't have to write an entire substitution table for accented chars
 
if lang == "DE" then
 
if lang == "DE" then
 
villagerlist = string.gsub(villagerlist, "Zwerg Icon", "Dwarf Icon")
 
villagerlist = string.gsub(villagerlist, "Zwerg Icon", "Dwarf Icon")
Ligne 229 : Ligne 246 :  
elseif lang == "FR" then
 
elseif lang == "FR" then
 
villagerlist = string.gsub(villagerlist, "Nain Icon", "Dwarf Icon")
 
villagerlist = string.gsub(villagerlist, "Nain Icon", "Dwarf Icon")
villagerlist = string.gsub(villagerlist, "Sorcier Icon", "Wizard Icon")
+
villagerlist = string.gsub(villagerlist, "Sorcier Icon", "Wizard Icon")
villagerlist = string.gsub(villagerlist, "Robine Icon", "Robin Icon")
+
villagerlist = string.gsub(villagerlist, "Robine Icon", "Robin Icon")
 +
--This is hacky, but it works
 +
villagerlist = string.gsub(villagerlist, "Leo", "Léo")
 
villagerlist = string.gsub(villagerlist, "Léo Icon", "Leo Icon")
 
villagerlist = string.gsub(villagerlist, "Léo Icon", "Leo Icon")
 
elseif lang == "IT" then
 
elseif lang == "IT" then
Ligne 307 : Ligne 326 :  
elseif lang == "HU" then
 
elseif lang == "HU" then
 
villagerlist = string.gsub(villagerlist, "Törpe Icon", "Dwarf Icon")
 
villagerlist = string.gsub(villagerlist, "Törpe Icon", "Dwarf Icon")
villagerlist = string.gsub(villagerlist, "Varázsló Icon", "Wizard Icon")
+
villagerlist = string.gsub(villagerlist, "Varázsló Icon", "Wizard Icon")
 
elseif lang == "PT" then
 
elseif lang == "PT" then
 
villagerlist = string.gsub(villagerlist, "Anão Icon", "Dwarf Icon")
 
villagerlist = string.gsub(villagerlist, "Anão Icon", "Dwarf Icon")
105 789

modifications