Modulo:String: differenze tra le versioni

mediawiki>Yusur-kun
vedi https://it.wikipedia.org/wiki/Modulo:String
 
m Annullata la modifica di Coccopuffo2018 (discussione), riportata alla versione precedente di Ropentiumal
Etichetta: Rollback
 
(3 versioni intermedie di 2 utenti non mostrate)
Riga 1: Riga 1:
-- Questo modulo usa la licenza Creative Commons di Wikipedia
-- Copiato da: https://it.wikipedia.org/wiki/Modulo:String
--
--[[
--[[


Riga 438: Riga 434:
function str.collate( frame )
function str.collate( frame )


     local collation = {  
     local collation = {
         {'[áàăắằẵẳâấầẫẩǎåǻäǟãȧǡąāảȁȃạặậḁⱥᶏᴂæɐᶐɒə]', 'a'},
         { '[áàăắằẵẳâấầẫẩǎåǻäǟãȧǡąāảȁȃạặậḁⱥᶏᴂɐᶐɒ]' , 'a'},
         {'[ÁÀĂẮẰẴẲÂẤẦẪẨǍÅÅǺÄǞÃȦǠĄĀẢȀȂẠẶẬḀȺᴁÆƏ]', 'A'},
         {'[ÁÀĂẮẰẴẲÂẤẦẪẨǍÅÅǺÄǞÃȦǠĄĀẢȀȂẠẶẬḀȺᴁ]', 'A'},
         {'[ḃḅḇƀɓ]', 'b'},
         {'[ḃḅḇbƀɓ]', 'b'},
         {'[ḂḄḆɃ]', 'B'},
         {'[ḂḄḆɃ]', 'B'},
         {'[ćĉčċçḉȼƈ]', 'c'},
         {'[ćĉčċçḉȼƈ]', 'c'},
         {'[ĆĈČĊÇḈȻƇ]', 'C'},
         {'[ĆĈČĊÇḈȻƇ]', 'C'},
         {'[đḍḓḏðďḋḑ]', 'd'},
         {'[đḍḓḏðď]', 'd'},
         {'[ĐḌḒḎÐĎḊḐ]', 'D'},
         {'[ĐḌḒḎÐĎ]', 'D'},
         {'[éèĕěêếềễểëẽėȩḝęēḗḕẻȅȇẹệḙḛǝ]', 'e'},
         {'[éèèêếềễểěëẽėȩḝęēḗḕẻȅȇẹệḙḛǝ]', 'e'},
         {'[ÉÈĔĚÊẾỀỄỂËẼĖȨḜĘĒḖḔẺȄȆẸỆḘḚƎ]', 'E'},
         {'[ÉÈÈÊẾỀỄỂĚËẼĖȨḜĘĒḖḔẺȄȆẸỆḘḚƎ]', 'E'},
         {'[ḟⅎ]', 'f'},
         {'[ḟⅎ]', 'f'},
         {'[ḞℲ]', 'F'},
         {'[ḞℲ]', 'F'},
Riga 467: Riga 463:
         {'[ńǹňñṅņṇṋṉ]', 'n'},
         {'[ńǹňñṅņṇṋṉ]', 'n'},
         {'[ŃǸŇÑṄŅṆṊṈ]', 'N'},
         {'[ŃǸŇÑṄŅṆṊṈ]', 'N'},
         {'[óòŏốồỗổǒôöȫőõṍṏȭȯȱøǿǫǭōṓṑỏȍȏơớờỡởợọộœ]', 'o'},
         {'[óòŏôốồỗổǒöȫőõṍṏȭȯȱøǿǫǭōṓṑỏȍȏơớờỡởợọộ]', 'o'},
         {'[ÓÒŎỐỒỖỔǑÔÖȪŐÕṌṎȬȮȰØǾǪǬŌṒṐỎȌȎƠỚỜỠỞỢỌỘŒ]', 'O'},
         {'[ÓÒŎÔỐỒỖỔǑÖȪŐÕṌṎȬȮȰØǾǪǬŌṒṐỎȌȎƠỚỜỠỞỢỌỘ]', 'O'},
         {'[ṕṗ]', 'p'},
         {'[ṕṗ]', 'p'},
         {'[ṔṖ]', 'P'},
         {'[ṔṖ]', 'P'},
         {'[ŕřṙŗȑȓṛṝṟ]', 'r'},
         {'[ŕřṙŗȑȓṛṝṟ]', 'r'},
         {'[ŔŘṘŖȐȒṚṜṞ]', 'R'},
         {'[ŔŘṘŖȐȒṚṜṞ]', 'R'},
         {'[śṥŝṧṡşṣṩșšß]', 's'},
         {'[śṥŝšṧṡşṣṩș]', 's'},
         {'[ŚṤŜṦṠŞṢṨȘŠ]', 'S'},
         {'[ŚṤŜŠṦṠŞṢṨȘ]', 'S'},
         {'[ťṫẗţṭțṱṯ]', 't'},
         {'[ťṫẗţṭțṱṯ]', 't'},
         {'[ŤṪŢṬȚṰṮ]', 'T'},
         {'[ŤṪŢṬȚṰṮ]', 'T'},
Riga 537: Riga 533:
         name = par_name,
         name = par_name,
         base_name = mw.ustring.gsub(par_name, ' ?#', '', 1),
         base_name = mw.ustring.gsub(par_name, ' ?#', '', 1),
         alt = alt_name
         alt = alt_name or ''
     }, Param)
     }, Param)
end
end
Riga 551: Riga 547:
function Param:get_first_value(args, index, base_index)
function Param:get_first_value(args, index, base_index)
     function value_or_nil (s)
     function value_or_nil (s)
         if s and s ~= '' then return s end
         if s and s~= '' then return s end
         return nil
         return nil
     end
     end
Riga 559: Riga 555:
     end
     end
     if index == base_index then
     if index == base_index then
         return value_or_nil(args[mw.ustring.gsub(self.name, '#', tostring(index), 1)]) or
         return value_or_nil(args[mw.ustring.gsub(self.name, '#', tostring(index), 1)]) or  
               value_or_nil(args[self.base_name]) or value_or_nil(args[self.alt]) or '', false
               value_or_nil(args[self.base_name]) or value_or_nil(args[self.alt]) or '', false
     else
     else
         return value_or_nil(args[mw.ustring.gsub(self.name, '#', tostring(index), 1)]) or
         return value_or_nil(args[mw.ustring.gsub(self.name, '#', tostring(index), 1)]) or  
               value_or_nil(args[self.alt]) or '', false
               value_or_nil(args[self.alt]) or '', false
     end
     end
Riga 659: Riga 655:
     while true do
     while true do
         local par_name = base_args['par' .. index] or (index == 1 and base_args['par']) or ''
         local par_name = base_args['par' .. index] or (index == 1 and base_args['par']) or ''
         if par_name == '' then break end
         if par_name == '' then break end;
         --carico eventuale nome alternativo per il primo parametro
         --carico eventuale nome alternativo per il primo parametro
         local alt_name = base_args['altpar' .. index] or (index == 1 and base_args['altpar']) or nil
         local alt_name = base_args['altpar' .. index] or (index == 1 and base_args['altpar']) or ''
         params[index] = Param(par_name, alt_name)
         params[index] = Param(par_name, alt_name)
         index = index + 1
         index = index + 1
Riga 683: Riga 679:
         local v, is_index = param:get_first_value(args, index, base_index)
         local v, is_index = param:get_first_value(args, index, base_index)
         if (not(is_index) or base_index<=Nobbligatori) and v ~= '' then found = true end
         if (not(is_index) or base_index<=Nobbligatori) and v ~= '' then found = true end
         message:add_value(mw.text.trim(v))
         message:add_value(v)
     end
     end
     if found then
     if found then
Riga 697: Riga 693:
             local v, is_index = param:get_other_value(args, index)
             local v, is_index = param:get_other_value(args, index)
             if (not(is_index) or index<=Nobbligatori) and v ~= '' then found = true end
             if (not(is_index) or index<=Nobbligatori) and v ~= '' then found = true end
             message:add_value(mw.text.trim(v))
             message:add_value(v)
         end
         end
         if found then
         if found then