모듈:usex/templates예문과 관련된 기능을 담당하는 모듈입니다.

  • usex: 예문 텍스트 (필수)[해설 1]
  • lang: 예문 언어의 ISO 언어코드 (필수)
  • termlang: 텍스트와 다른 용어의 언어 객체 (기본값은 lang).
  • sc: 텍스트의 스크립트 객체 (지정되지 않으면 자동 감지).
  • quote: 인용문일 경우 지정 (CSS 클래스가 다르게 적용).[해설 2]
  • inline: 인라인 형식으로 표시할 경우 지정.
  • translation: 외국어 예문 또는 인용문의 번역.
  • lit: 문자 그대로의 번역 (번역이 관용적일 경우).
  • normalization: 비표준 철자가 흔한 오래된 언어의 예문 또는 인용문의 표준화된 버전.
  • normsc: 표준화된 텍스트의 스크립트 객체.
  • transliteration: 예문의 음역 (지정되지 않으면 표준화된 텍스트를 음역).
  • transcription: 발음과 음역이 크게 다른 언어의 경우 예문의 전사.
  • subst: 음역 전에 예문/인용문과 표준화 텍스트에 수행할 대체 문자열.
  • q: 예문/인용문 텍스트 앞에 표시할 왼쪽 수식어 목록.
  • qq: 예문/인용문 텍스트 뒤에 표시할 오른쪽 수식어 목록.
  • translation: 한국어 외 단어에 대한 예문의 번역[해설 3]
  • ref: 출처 표시를 담당합니다.
  • orig: 원문 텍스트[해설 3]

해설

편집
  1. 만약 없을 경우 예외처리 구문을 생성합니다.
  2. 예문의 화자가 다른 화자의 말을 인용하는 상황을 가정하고 있을 경우, 이 옵션을 적용할 수 있습니다.
  3. 3.0 3.1 "차라투스트라는 이렇게 말했다"는 한국어로 쓰여졌지만 독일어를 사용하는 니체의 독일어 어록을 한국어로 번역한 것입니다. 말하다의 예문을 작성하기 위해 "차라투스트라는 이렇게 말했다"를 예문으로 사용할 수 있지만, 그것에 대한 독일어 원문을 표시하고 싶다면 orig이 사용됩니다.

-- Module:usex/templates
local export = {}

local m_languages = require("Module:languages")
local table_module = "Module:table"
local usex_module = "Module:usex"
local usex_ja_module = "Module:usex/ja"

local rsplit = mw.text.split
local rfind = mw.ustring.find

local function track(page)
    require("Module:debug/track")("usex/templates/" .. page)
    return true
end

function export.fetch_categories(lang, param)
    -- 분류 테이블 생성
    local categories = {}
    
    -- 분류 삽입 함수
    local function insert_cat(cat)
        table.insert(categories, cat)
    end
    
    insert_cat("구식화된 예문 매개변수 [" .. param .. "] 사용/" .. lang)
    
    return categories
end

function export.usex_t(frame)
    -- Invocation arguments (passed in the template #invoke call).
    local iparams = {
        ["quote"] = {},
        ["compat"] = {type = "boolean"},
        ["inline"] = {type = "boolean"},
        ["nocat"] = {type = "boolean"},
        ["class"] = {},
    }

    local iargs = require("Module:parameters").process(frame.args, iparams)
    local compat = iargs.compat

    -- Template (parent) arguments.
    local params = {
        -- Usex/quotation text parameters
        [1] = {required = true},
        [2] = {},
        [3] = {},
        ["termlang"] = {},
        ["tr"] = {},
        ["transliteration"] = {alias_of = "tr"},
        ["ts"] = {},
        ["transcription"] = {alias_of = "ts"},
        ["sc"] = {},
        ["norm"] = {},
        ["normalization"] = {alias_of = "norm"},
        ["normsc"] = {},
        ["subst"] = {},
        ["q"] = {list = true},
        ["qualifier"] = {alias_of = "q"},
        ["qq"] = {list = true},
        ["ref"] = {},

        -- Translation of usex text
        [4] = {}, -- 네 번째 매개변수 추가
        ["t"] = {alias_of = 4},
        ["translation"] = {alias_of = 4},
        ["lit"] = {},

        -- Original text, if the usex/quotation is a translation
        ["orig"] = {},
        ["origlang"] = {},
        ["origtr"] = {},
        ["origts"] = {},
        ["origsc"] = {},
        ["orignorm"] = {},
        ["orignormsc"] = {},
        ["origsubst"] = {},
        ["origq"] = {list = true},
        ["origqq"] = {list = true},
        ["origref"] = {},

        -- Citation-related parameters; for anything more complex, usex {{quote-*}}
        ["source"] = {},
        ["footer"] = {},

        -- Formatting parameters
        ["inline"] = {type = "boolean"},
        ["brackets"] = {type = "boolean"},

        -- Categorization parameters
        ["nocat"] = {type = "boolean"},
        ["sort"] = {},
    }

    -- 구식화된 매개변수를 위한 딕셔너리 생성
    local deprecatedParams = {
        ["언어"] = false,
        ["원문"] = false,
        ["발음"] = false,
        ["외래어표기법"] = false,
        ["외국말적기법"] = false
    }

    if compat then
        params["lang"] = {required = true}
        params["t"].alias_of = 2
        params["translation"].alias_of = 2
        table.remove(params, 1)
    end
    
    for p, _ in pairs(deprecatedParams) do
        if frame:getParent().args[p] then
            deprecatedParams[p] = true
        end
    end
    
    if deprecatedParams["언어"] then
        params[1] = frame:getParent().args["언어"]
    end

    local args = require("Module:parameters").process(frame:getParent().args, params)
    local langparam = compat and "lang" or 1
    local lang = m_languages.getByCode(args[langparam] or "und", langparam, "allow etym")
    local sc = args.sc
    sc = sc and require("Module:scripts").getByCode(sc, "sc") or nil
    local normsc = args.normsc
    normsc = normsc == "auto" and normsc or normsc and require("Module:scripts").getByCode(normsc, "normsc") or nil
    if normsc and not args.norm then
        error("Cannot specify normsc= without norm=")
    end

    if #args.qq > 0 then
        track("qq")
    end
    if #args.q > 0 then
        track("q")
    end

    local termlang
    if args.termlang then
        termlang = m_languages.getByCode(args.termlang, "termlang", "allow etym")
        table.insert(args.qq, 1, "in " .. lang:getCanonicalName())
    end

    local origlang, origsc, orignormsc
    if args.orig then
        origlang = m_languages.getByCode(args.origlang, "origlang", "allow etym")
        table.insert(args.origqq, 1, "in " .. origlang:getCanonicalName())
        origsc = args.origsc
        origsc = origsc and require("Module:scripts").getByCode(origsc, "origsc") or nil
        orignormsc = args.orignormsc
        orignormsc = orignormsc == "auto" and orignormsc or
            orignormsc and require("Module:scripts").getByCode(orignormsc, "normsc") or nil
        if orignormsc and not args.orignorm then
            error("Cannot specify orignormsc= without orignorm=")
        end
    else
        for _, noparam in ipairs { "origlang", "origtr", "origts", "origsc", "orignorm", "orignormsc", "origsubst",
            "origref" } do
            if args[noparam] then
                error(("Cannot specify %s= without orig="):format(noparam))
            end
        end
        if #args.origq > 0 then
            error("Cannot specify origq= without orig=")
        end
        if #args.origqq > 0 then
            error("Cannot specify origqq= without orig=")
        end
    end

    local usex, translation, tr

    -- ja 하위 모듈 호출
    if lang:getCode() == "ja" then
        local ja_module = require(usex_ja_module)
        local ja_result = ja_module.show(frame)

        -- ja_result에서 필요한 매개변수를 추출하여 args에 추가
        usex = ja_result.usex
        tr = ja_result.tr
        translation = ja_result.translation
    else
        usex = args[compat and 1 or 2]
        translation = args[compat and 2 or 3]
        tr = args.tr
    end

    local data = {
        lang = lang,
        sc = sc,
        normsc = normsc,
        usex = usex,
        translation = translation,
        transliteration = tr,
        transcription = args.ts,
        normalization = args.norm,
        inline = args.inline or iargs.inline,
        ref = args.ref,
        quote = iargs.quote,
        lit = args.lit,
        subst = args.subst,
        -- FIXME, change to left and right qualifiers
        qq = #args.qq > 0 and args.qq or args.q,
        source = args.source,
        footer = args.footer,
        nocat = args.nocat or iargs.nocat,
        brackets = args.brackets,
        sortkey = args.sort,
        class = iargs.class,

        -- Original text, if the usex/quotation is a translation
        orig = args.orig,
        origlang = origlang,
        origtr = args.origtr,
        origts = args.origts,
        origsc = origsc,
        orignorm = args.orignorm,
        orignormsc = orignormsc,
        origsubst = args.origsubst,
        origq = args.origq,
        origqq = args.origqq,
        origref = args.origref,
    }

    -- ja 언어에 대해 특별 처리
    if lang:getCode() == "ja" then
        return data.usex
    else
        return require(usex_module).format_usex(data)
    end
end

local ignore_prefixes = {"사용자:", "토론:",
    "위키낱말사전:자유게시판", "Wiktionary:Translation requests",
    "Wiktionary:Grease pit", "Wiktionary:Etymology scriptorium",
    "Wiktionary:Information desk", "Wiktionary:Tea room",
    "Wiktionary:Requests for", "Wiktionary:Votes"
}

function export.page_should_be_ignored(page)
    -- Ignore user pages, talk pages and certain Wiktionary pages
    for _, ip in ipairs(ignore_prefixes) do
        if rfind(page, "^" .. ip) then
            return true
        end
    end
    if rfind(page, " talk:") then
        return true
    end
    return false
end

function export.page_should_be_ignored_t(frame)
    return export.page_should_be_ignored(frame.args[1]) and "true" or ""
end

return export