Module:Damage: Difference between revisions

extract title function to Module:i18n
(Add PvE and PvP template translation)
(extract title function to Module:i18n)
Line 146: Line 146:
             local passive_values = split(is_custom and v or
             local passive_values = split(is_custom and v or
                 frame:preprocess('{{:' .. passive_name .. '}}{{#arrayprint:' .. passive_name .. '}}'));
                 frame:preprocess('{{:' .. passive_name .. '}}{{#arrayprint:' .. passive_name .. '}}'));
            local display_title


            local display_title
             if is_custom then
             if is_custom then
                 passive_name = passive_values[#passive_values]
                 passive_name = passive_values[#passive_values]
Line 156: Line 156:
                 Customized will override this name, thus no need to perform the translation
                 Customized will override this name, thus no need to perform the translation
                 --]]
                 --]]
                 local translated_page = mw.title.makeTitle('', passive_title)
                 display_title = i18n.getTranslatedTitle(passive_title)
                if translated_page.exists then
                    display_title = string.match(translated_page:getContent(), "%{%{DISPLAYTITLE:([^}]-)%}%}")
                end
             end
             end