Fandom

Narutopedia

Module:Translation

6,207pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

-- @author: UltimateSupreme
local p, flag = {}, false
local yn = require( 'Module:Yesno' )
local err = require( 'Module:Error' )
 
-- Check if the arg exists
-- If yes, append it to the text
local function append(label, arg, text, lang)
 
    local c = flag and ", " or " ("
    local t = text
 
    if yn(arg) then
        flag = true
        if lang then
            arg = tostring(
                mw.html.create("span")
                :attr("lang", lang)
                :wikitext(arg)
            )
        end
 
        if label then
            t = t..c.."''"..label..":'' "..arg
        else t = t..c..arg
        end
    end
 
    return t
end
 
function p.rubify(base, ann)
    return "<ruby lang=ja>"..base.."<rp>, </rp><rt>"..ann.."</rt></ruby>"
end
 
function p.translate(frame)
    local args = frame:getParent().args
 
    if not yn(args[1]) then return err("Provide an official name") end
 
    local text = args[1]
 
    if args.furigana then args[2] = p.rubify(args[2], args.furigana) end
    text = append(nil, args[2], text, "ja")
 
    if yn(args[3]) then
        text = append(nil, "''"..args[3].."''", text)
    end
 
    text = append("English", args.eng, text)
    text = append("Latin", args.latin, text, "la")
    text = append("FUNimation", args.funi, text)
    text = append("Viz", args.viz, text)
    text = append("English TV", args.engtv, text)
    text = append("UK DVD", args.ukdvd, text)
    text = append("Fansub", args.fansub, text)
    text = append("Literally meaning", args["lit meaning"], text)
    text = append("Meaning (Viz)", args["viz meaning"], text)
    text = append("Meaning (English TV)", args["engtv meaning"], text)
    text = append(nil, args[4], text) --extra
 
    return text..(flag and ")" or "")
end
return p
 
--[[Category:Lua Modules]]

Also on Fandom

Random Wiki