モジュール:uz-inflection

出典: フリー多機能辞典『ウィクショナリー日本語版(Wiktionary)』
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:uz-inflection/doc に作成できます

-- Inflection module v2.0.3
-- 2015-08-14

local dev_prefix = 'uz-'
-- dev_prefix = 'User:Vitalik/'  -- comment this on active version

local export = {}
local u = require("モジュール:uz-utils")

-- Function to load corresponding unit
local function load_unit(unit_name)
	if unit_name == '' then
		return nil
	end
	return require("モジュール:" .. dev_prefix .. "inflection/units/" .. unit_name);
end

-- This export function is used from testcases
function export.test(unit_name, base, args)
	local unit = load_unit(unit_name)
	return unit.forms(base, args)
end

-- This export function is used from templates
function export.get(frame)
	local base = u.get_base()
	local args = frame:getParent().args
	local unit_name = frame.args['unit']
	local unit = load_unit(unit_name)
	if unit == nil then
		return 'Error: Name of unit is absent'
	end
	return frame:expandTemplate{
		title=unit.template(base, args), 
		args=unit.forms(base, args)
	}
end

return export