Modul:WikidataDescription: Perbedaan antara revisi
Tampilan
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan |
Tidak ada ringkasan suntingan |
||
(2 revisi perantara oleh pengguna yang sama tidak ditampilkan) | |||
Baris 4: | Baris 4: | ||
function p._fromQID(qid, prefix) |
function p._fromQID(qid, prefix) |
||
local prefix = prefix or '' |
local prefix = prefix or '' |
||
local qid1 = qid or '' |
|||
local result, lang = mw.wikibase.getDescriptionWithLang(qid) |
local result, lang = mw.wikibase.getDescriptionWithLang(qid) |
||
local tes = string.sub(lang,0,2) |
local tes = string.sub(lang,0,2) |
||
-- don't get english fallback results |
-- don't get english fallback results |
||
if result and string.sub(lang,0,2) == 'id' then |
|||
return |
return prefix .. result |
||
else |
|||
return '' |
|||
end |
|||
end |
end |
||
Baris 23: | Baris 22: | ||
-- {{#Invoke:WikidataDescription|fromTitle|RELN|,}} => ", gen pengkode-protein pada manusia" (dari https://www.wikidata.org/wiki/Q414043) |
-- {{#Invoke:WikidataDescription|fromTitle|RELN|,}} => ", gen pengkode-protein pada manusia" (dari https://www.wikidata.org/wiki/Q414043) |
||
function p.fromTitle(frame) |
function p.fromTitle(frame) |
||
local resolveEntityId = require( "Module:ResolveEntityId" )._id |
|||
⚫ | |||
id = resolveEntityId( frame.args[1]) |
|||
⚫ | |||
end |
end |
||
Revisi terkini sejak 19 Desember 2022 18.24
-- Simple wrapper for mw.wikibase.description
local p = {}
function p._fromQID(qid, prefix)
local prefix = prefix or ''
local result, lang = mw.wikibase.getDescriptionWithLang(qid)
local tes = string.sub(lang,0,2)
-- don't get english fallback results
if result and string.sub(lang,0,2) == 'id' then
return prefix .. result
else
return ''
end
end
function p.fromQID(frame)
return p._fromQID(frame.args[1], frame.args[2])
end
-- contoh
-- {{#Invoke:WikidataDescription|fromTitle|reelin}} => "protein" (dari https://www.wikidata.org/wiki/Q13561329)
-- {{#Invoke:WikidataDescription|fromTitle|RELN|,}} => ", gen pengkode-protein pada manusia" (dari https://www.wikidata.org/wiki/Q414043)
function p.fromTitle(frame)
local resolveEntityId = require( "Module:ResolveEntityId" )._id
id = resolveEntityId( frame.args[1])
return p._fromQID(id, frame.args[2])
end
return p