Mô đun:DynamicPageList
Bước tới điều hướng
Bước tới tìm kiếm
local p = {}
local stats = require "Module:Thống kê Wiktionary"
local scripts = require "Module:Chữ viết"
function p.newEntriesForLanguage(frame, category, excludeCategories, anchor, count)
if not excludeCategories then excludeCategories = {""} end
local html = mw.text.unstrip(frame:callParserFunction{
name = "#tag:DynamicPageList",
args = {
mw.ustring.format([=[
namespace = 0
category = %s
notcategory = Không đưa lên Trang Chính
notcategory = %s
stablepages = only
count = %i
order = descending
mode = none
]=], category or "", table.concat(excludeCategories, "\nnotcategory = "), count),
},
})
local linkFmt = "[[%s]]"
if anchor then linkFmt = "[[%s#" .. anchor .. "|%s]]" end
local entries = mw.text.split(mw.ustring.gsub(html, '<a href=".-" title=".-">(.-)</a><br /> ?', "%1"), "\n")
if #entries[1] < 1 then table.remove(entries, 1) end
if #entries[#entries] < 1 then table.remove(entries, #entries) end
local lookupTable = {}
if category then
for i, entry in ipairs(entries) do lookupTable[entry] = true end
end
local links = {}
for i, entry in ipairs(entries) do
links[i] = mw.ustring.format(linkFmt, entries[i], entries[i])
end
return entries, links, lookupTable
end
p["mục từ mới"] = function (frame)
local _, vieLinks, vieLookupTable = p.newEntriesForLanguage(frame, "Mục từ tiếng Việt", nil, "Tiếng Việt", 15)
local _, engLinks, engLookupTable = p.newEntriesForLanguage(frame, "Mục từ tiếng Anh", nil, "Tiếng Anh", 15)
local etc, etcLinks = p.newEntriesForLanguage(frame, nil, {"Mục từ tiếng Việt", "Mục từ tiếng Anh"}, nil, 15)
for i, link in ipairs(etcLinks) do
local script = scripts.scriptForText(etc[i])
if script then
etcLinks[i] = mw.ustring.format("<span class='%s'>%s</span>", script, link)
end
end
return mw.ustring.format([=[
; %s
: %s
; %s
: <span lang="en">%s</span>
; %s
: <span lang="mul">%s</span>
]=],
mw.message.new("Wiktionary-mp-newentries-vie"):plain(),
table.concat(vieLinks, ", "),
mw.message.new("Wiktionary-mp-newentries-eng"):plain(),
table.concat(engLinks, ", "),
mw.message.new("Wiktionary-mp-newentries-other"):params{
stats["số ngôn ngữ"]() - 2,
}:plain(),
table.concat(etcLinks, ", "))
end
return p