Modul:rhymes
Bu modul uchun Modul:rhymes/doc nomli hujjat sahifasini yaratishingiz mumkin
local export = {}
local m_MFA = require("Module:MFA")
local function make_rhyme_link(tili, link_MFA, display_MFA)
if not link_IPA then
return table.concat{'[[Rhymes:', tili:getCanonicalName(), '|', tili:getCanonicalName(), ']]'}
else
local formatted_MFA, cat = m_MFA.format_MFA(tili, display_MFA or link_MFA, true)
return table.concat{'[[Rhymes:', tili:getCanonicalName(), '/', link_MFA, '|', formatted_MFA, ']]', cat}
end
end
function export.show_row(frame)
local params = {
[1] = {required = true},
[2] = {required = true},
[3] = {},
}
local args = frame.getParent and frame:getParent().args or frame
if (not args[1] or args[1] == '') and mw.title.getCurrentTitle().nsText == "Andoza" then
return '[[Rhymes:English/aɪmz|<span class="IPA">-aɪmz</span>]]'
end
local args = require("Module:parameters").process(args, params)
local tili = require("Module:tili").getByCode(args[1]) or require("Module:tili").err(args[1], 1)
return make_rhyme_link(tili, args[2], '-' .. args[2]) .. (args[3] and (" (''" .. args[3] .. "'')") or '')
end
function export.show(frame)
local params = {
[1] = {required = true, list = true},
tili = {required = true},
}
local args = frame.getParent and frame:getParent().args or frame
if (not args[1] or args[1] == '') and mw.title.getCurrentTitle().nsText == "Andoza" then
return 'Qofiyalar: [[Rhymes:English/aɪmz|<span class="IPA">-aɪmz</span>]]'
end
local args = require("Module:parameters").process(args, params)
local tili = require("Module:tili").getByCode(args.tili) or require("Module:tili").err(args.tili, "tili")
local links = {}
for _, r in ipairs(args[1]) do
table.insert(links, make_rhyme_link(tili, r, '-' .. r))
end
return "Qofiyalar: " .. table.concat(links, ', ')
end
function export.show_nav(frame)
-- Gather parameters
local args = frame:getParent().args
local tili = args[1] or (mw.title.getCurrentTitle().nsText == "Andoza" and "und") or error("Language code has not been specified. Please pass parameter 1 to the template.")
tili = require("Module:tili").getByCode(tili) or require("Module:tili").err(tili, 1)
local parts = {}
local i = 2
while args[i] do
local part = args[i]; if part == "" then part = nil end
table.insert(parts, part)
i = i + 1
end
-- Create steps
local steps = {"» [[Wiktionary:Qofiya|Qofiyalar]]", "» " .. make_rhyme_link(tili)}
local categories = {}
if #parts > 0 then
local last = parts[#parts]
parts[#parts] = nil
local prefix = ""
for i, part in ipairs(parts) do
prefix = prefix .. part
parts[i] = prefix
end
for _, part in ipairs(parts) do
table.insert(steps, "» " .. make_rhyme_link(lang, part .. '-', '-' .. part .. '-'))
end
if last == "-" then
table.insert(steps, "» " .. make_rhyme_link(lang, prefix, '-' .. prefix))
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " qofiyalar" .. (prefix == "" and "" or "/" .. prefix .. "-") .. "| ]]")
elseif mw.title.getCurrentTitle().text == lang:getCanonicalName() .. "/" .. prefix .. last .. "-" then
table.insert(steps, "» " .. make_rhyme_link(lang, prefix .. last .. '-', "-" .. prefix .. last .. "-"))
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " qofiyalar/" .. prefix .. last .. "-|-]]")
else
table.insert(steps, "» " .. make_rhyme_link(lang, prefix .. last, "-" .. prefix .. last))
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " qofiyalar" .. (prefix == "" and "" or "/" .. prefix .. "-") .. "|" .. last .. "]]")
end
elseif lang ~= "und" then
table.insert(categories, "[[Category:" .. lang:getCanonicalName() .. " qofiyalar| ]]")
end
return table.concat(steps, " ") .. table.concat(categories)
end
return export