모듈:일본어

하늘 (토론 | 기여)님의 2021년 4월 29일 (목) 18:21 판
설명문서 [편집] [역사] [새로고침]

삭제는 사용자들의 토론에 따라 결정됩니다.
다른 의견이 있으면 틀을 {{삭제보류}}로 바꿔 달아주시고, 토론 문서에서 문서의 삭제에 관해 토론해주세요.


삭제는 사용자들의 토론에 따라 결정됩니다.
다른 의견이 있으면 틀을 {{삭제보류}}로 바꿔 달아주시고, 토론 문서에서 문서의 삭제에 관해 토론해주세요.


연습장이나 사용자 문서에서 틀의 사용이나 수정을 연습할 수 있습니다.
분류는 /설명문서에 넣어주세요.

local jp = { }

function jp.postposition (termination, conjugation) --조사
    if (termination == "く") or (termination == "す") or (termination == "る") or (termination == "う") or (termination == "つ") then
        return conjugation
    else
        if conjugation == "て" then return "で"
        elseif conjugation == "ます" then return "ます"
        else return "ない" end
    end
end

function jp.converter(termination, conjugation)
    if "く" == termination then
        if conjugation == "て" then return "い"
        elseif conjugation == "ます" then return "き"
        else return "か" end
    elseif "ぐ" == termination then
        if conjugation == "て" then return "い"
        elseif conjugation == "ます" then return "ぎ"
        else return "が" end
    elseif "す" == termination then
        if conjugation == "て" then return "し"
        elseif conjugation == "ます" then return "し"
        else return "さ" end
    elseif "ぬ" == termination then
        if conjugation == "て" then return "ん"
        elseif conjugation == "ます" then return "に"
        else return "な" end
    elseif "ぶ" == termination then
        if conjugation == "て" then return "ん"
        elseif conjugation == "ます" then return "び"
        else return "ば" end
    elseif "む" == termination then
        if conjugation == "て" then return "ん"
        elseif conjugation == "ます" then return "み"
        else return "ま" end
    elseif "る" == termination then
        if conjugation == "て" then return "っ"
        elseif conjugation == "ます" then return "り"
        else return "ら" end
    elseif "う" == termination then
        if conjugation == "て" then return "っ"
        elseif conjugation == "ます" then return "い"
        else return "わ" end
    elseif "つ" == termination then
        if conjugation == "て" then return "っ"
        elseif conjugation == "ます" then return "ち"
        else return "た" end
    else
    end
end

function jp.main(frame)
	
	local kanji = frame.args['kanji'] --"遊" --한자
    local furigana = frame.args['furigana'] -- "あそ" --후리가나
    local hiragana = frame.args['hiragana'] -- "あそぶ" --히라가나
    local conjugation = frame.args['conjugation'] --"て" --활용
    local termination --"" --어미
    local okurigana --"" --오쿠리가나
    
    if (kanji == "来") then
        if conjugation == "ない" then
            furigana = "こ"
        else
            furigana = "き"
        end
        rubi = "{{루비|"..kanji.."|"..furigana.."}}"
        return rubi..conjugation

    else
        okurigana = string.gsub( hiragana, furigana, "" )
        if string.len( okurigana ) > 1 then
            termination = string.sub( okurigana, 0, - 1)
        else
            termination = okurigana
        end
        rubi = "<ruby><rb>"..kanji..[[</rb><rt style{{=}}"font-size: 70%">]]..furigana.."</rt></ruby>"
        
        return rubi..jp.converter(termination, conjugation)..jp.postposition(conjugation)
    end
end

return jp