Module:CharTree/zh-hant: Difference between revisions

From Elwiki
No edit summary
Tag: Manual revert
No edit summary
Line 51: Line 51:
         end
         end
          
          
        for job_iter, job_name in ipairs(jobs) do
for job_iter, job_name in ipairs(jobs) do
            for path_iter, path_name in ipairs(job_name) do
    for path_iter, path_name in ipairs(job_name) do
                -- Foreign languages
        -- 分離顯示名稱和圖標名稱
                local icon_link_char_name = path_name;
        local icon_link_char_name = path_name
                local normal_link_char_name = path_name;
        local normal_link_char_name = path_name
                if str_localized(path_name) then
        local display_name = path_name
                    local name_split = split_lang(path_name)
                    icon_link_char_name = name_split[1]:gsub(':', '')
                    path_name = name_split[2]
                    normal_link_char_name = name_split[1] .. lang
                end
                icon_link_char_name = icon_link_char_name:gsub(':', '')
                local icon_str = 'Icon - '
                local link = '|link=' .. normal_link_char_name
                local unreleased = indexOf(normal_link_char_name, not_exist)


                if unreleased then
        -- 如果有本地化名稱,提取英文名稱和顯示名稱
                    icon_str = ''
        if str_localized(path_name) then
                    icon_link_char_name = 'Dunno'
            local name_split = split_lang(path_name)
                    link = '|link=#!'
            icon_link_char_name = name_split[1]:gsub(':', '') -- 始終使用英文名稱作為圖標文件名
                end
            display_name = name_split[2] -- 使用本地化名稱(zh-hant)作為顯示名稱
            normal_link_char_name = name_split[1] .. lang -- 鏈接使用本地化格式
        else
            icon_link_char_name = path_name:gsub(':', '') -- 無本地化時直接使用 path_name
            display_name = path_name
            normal_link_char_name = path_name
        end
 
        -- 檢查未發布狀態
        local icon_str = 'Icon - '
        local link = '|link=' .. normal_link_char_name
        local unreleased = indexOf(normal_link_char_name, not_exist)
 
        if unreleased then
            icon_str = ''
            icon_link_char_name = 'Dunno'
            link = '|link=#!'
        end


                local icon_with_link = '[[File:' .. icon_str .. icon_link_char_name .. '.png' .. link .. ']]'
        -- 生成圖標 Wiki 語法
                local img = tree:tag('div'):addClass('char-banner-tree-image'):attr('data-class-name', path_name):wikitext(icon_with_link)
        local icon_with_link = '[[File:' .. icon_str .. icon_link_char_name .. '.png' .. link .. ']]'
        local img = tree:tag('div')
            :addClass('char-banner-tree-image')
            :attr('data-class-name', display_name) -- 使用本地化名稱作為顯示名稱
            :wikitext(icon_with_link)


                if unreleased then
        if unreleased then
                    img:attr('data-unreleased', 'true')
            img:attr('data-unreleased', 'true')
                end
            end
         end
         end
    end
end


         char_banner:node(tree)
         char_banner:node(tree)