모듈:한자/획순

설명문서 [편집] [역사] [새로고침]
연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는 /설명문서에 넣어주세요.

local p = {}
local html = mw.html
local title_ = mw.title
local uformat = mw.ustring.format

function p.strokeOrder_(title, hanja, file, lang)
    if hanja == nil then
        return
    end
    --local unicode = 'U+0' .. mw.ustring.upper(uformat("%x", mw.ustring.codepoint(hanja)))

    if file == '삭제' then
        return ''

    elseif file == '기본' or file == 'norm' or file == nil then
        local file_title
        if lang == "ja" then
            if title_.new(uformat('media:%s-jorder.gif', hanja)).exists then
                file = uformat('[[파일:%s-jorder.gif|100px]]', hanja)
            elseif title_.new(uformat('media:%s-jbw.png', hanja)).exists then
                file = uformat('[[파일:%s-jbw.png]]', hanja)
            end

        elseif title_.new(uformat('media:%s-order.gif', hanja)).exists then
            file = uformat('[[파일:%s-order.gif|100px]]', hanja)

        elseif title_.new(uformat('media:%s-bw.png', hanja)).exists then
            file = uformat('[[파일:%s-bw.png]]', hanja)

            --	elseif title_.new(uformat('file:%s - %s - KanjiVG stroke order.svg', hanja, unicode)).exists then
            --		class = 'NavFrame collapsed hanja-strokeorder KanjiVG'; file = uformat('[[파일:%s - %s - KanjiVG stroke order.svg|200px]]', hanja, unicode)

            --	elseif title_.new(uformat('file:%s - %s- KanjiVG stroke order.svg', hanja, unicode)).exists then
            --		class = 'NavFrame collapsed hanja-strokeorder KanjiVG'; file = uformat('[[파일:%s - %s- KanjiVG stroke order.svg|200px]]', hanja, unicode)
        else
            return ''
        end
    end

    return html.create('div'):addClass('mw-collapsible mw-collapsed hanja-strokeorder'):css('position', 'relative')
        :tag('div'):wikitext(title):done()
        :tag('div'):addClass('mw-collapsible-content'):wikitext(file):done()
end

function p.strokeOrder(frame)
    local args = require('Module:Arguments').getArgs(frame)
    local hanja = args[1]
    local title = args[2] or '획순 보기'
    local alter = args['대체']
    local lang = args['lang'] or args['locale'] or args['언어']
    return p.strokeOrder_(title, hanja, alter, lang)
end

return p