Module:CharTree: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 12: Line 12:
     local lang = '';
     local lang = '';
     if args.lang then lang = '/' .. args.lang end
     if args.lang then lang = '/' .. args.lang end
    local is_localized = lang and lang ~= ''
     local char_order = char_list[1]
     local char_order = char_list[1]
     local not_exist = char_list[3]
     local not_exist = char_list[3]
     local char_list = char_list[2]
     local char_list = char_list[2]


     local char_tree = mw.html.create('div'):addClass('char-banner-tree'):attr('data-base', args[1])
    function split_lang(str)
        return is_localized and split(str, lang .. '|') or str
    end
 
    function str_localized(str)
        return string.find(str, lang .. '|')
    end
 
    local base_name = split_lang(args[1])[2] or args[1]
     local char_tree = mw.html.create('div'):addClass('char-banner-tree'):attr('data-base', base_name)
     local out = ''
     local out = ''
     local char, file_name, link, nopath, nopathnojob, entry, image_arg, icon_str;
     local char, file_name, link, nopath, nopathnojob, entry, image_arg, icon_str;
     for char_iter=1, #char_order, 1 do
     for char_iter=1, #char_order, 1 do
         local base, jobs = char_order[char_iter], {{}, {}, {}}
         local base, jobs = char_order[char_iter], {{}, {}, {}}
        local base_name = split_lang(base)[1] or base
         local tree = mw.html.create('div'):addClass('char-banner-tree'):attr('data-base', base:gsub('/', ''))
         local tree = mw.html.create('div'):addClass('char-banner-tree'):attr('data-base', base:gsub('/', ''))


Line 44: Line 55:
                 local icon_link_char_name = file_name;
                 local icon_link_char_name = file_name;
                 local normal_link_char_name = path_name;
                 local normal_link_char_name = path_name;
                 if string.find(file_name, lang .. '|') then
                 if str_localized(file_name) then
                     local name_split = split(icon_link_char_name, lang .. '|')
                     local name_split = split_lang(icon_link_char_name)
                     icon_link_char_name = name_split[1]
                     icon_link_char_name = name_split[1]
                     path_name = name_split[2]
                     path_name = name_split[2]
Line 56: Line 67:
                 if unreleased then
                 if unreleased then
                     icon_str = ''
                     icon_str = ''
                     file_name = 'Dunno'
                     icon_link_char_name = 'Dunno'
                     link = '|link=#!'
                     link = '|link=#!'
                 end
                 end