Ero sivun ”Moduuli:WBDictionary” versioiden välillä
Siirry navigaatioon
Siirry hakuun
(Ak: Uusi sivu: local p = {} local lang = mw.language.getContentLanguage() local i18n = { ["errors"] = { ["entity-not-found"] = "Wikidata entity not found.", } } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Public functions ------------------------------------------------------------------------------- -----------------------------------------------------------------...) |
Ei muokkausyhteenvetoa |
||
Rivi 34: | Rivi 34: | ||
out[#out+1] = "<tr><td>" .. lang:ucfirst( mw.language.fetchLanguageName(v.language, lang:getCode() ) ).. "</td><td>" .. v.value .. "</td></tr>" | out[#out+1] = "<tr><td>" .. lang:ucfirst( mw.language.fetchLanguageName(v.language, lang:getCode() ) ).. "</td><td>" .. v.value .. "</td></tr>" | ||
end | end | ||
table.sort(out) | |||
return table.concat(out) | return table.concat(out) | ||
end | end |
Nykyinen versio 2. tammikuuta 2023 kello 18.08
Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:WBDictionary/ohje
local p = {} local lang = mw.language.getContentLanguage() local i18n = { ["errors"] = { ["entity-not-found"] = "Wikidata entity not found.", } } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Public functions ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- getAllLabels fetches the set of labels and formats it for display as tabel rows. -- It takes a parameter 'qid' for arbitrary access, otherwise it uses the current page. ------------------------------------------------------------------------------- -- Dependencies: none ------------------------------------------------------------------------------- p.getAllLabels = function(frame) local args = frame.args or frame:getParent().args or {} local qid = args.qid or "" if qid == "" then qid = mw.wikibase.getEntityIdForCurrentPage() end if not qid or not mw.wikibase.entityExists(qid) then return i18n["entity-not-found"] end local labels = mw.wikibase.getEntity(qid).labels if not labels then return i18n["labels-not-found"] end local out = {} for k, v in pairs(labels) do out[#out+1] = "<tr><td>" .. lang:ucfirst( mw.language.fetchLanguageName(v.language, lang:getCode() ) ).. "</td><td>" .. v.value .. "</td></tr>" end table.sort(out) return table.concat(out) end return p ------------------------------------------------------------------------------- -- List of exported functions ------------------------------------------------------------------------------- --[[ getAllLabels --]] -------------------------------------------------------------------------------