Modul:WikidataDescription: Perbedaan antara revisi
Tampilan
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan |
kTidak ada ringkasan suntingan |
||
Baris 7: | Baris 7: | ||
-- don't get english fallback results |
-- don't get english fallback results |
||
-- if result and string.sub(lang,0,2) == 'id' then |
-- if result and string.sub(lang,0,2) == 'id' then |
||
return lang .. prefix .. result |
return lang .. prefix -- .. result |
||
-- else |
-- else |
||
-- return '' |
-- return '' |
Revisi per 19 Desember 2022 17.55
-- Simple wrapper for mw.wikibase.description
local p = {}
function p._fromQID(qid, prefix)
local prefix = prefix or ''
local result, lang = mw.wikibase.getDescriptionWithLang(qid)
-- don't get english fallback results
-- if result and string.sub(lang,0,2) == 'id' then
return lang .. 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)
return p._fromQID(mw.wikibase.getEntityIdForTitle(frame.args[1]), frame.args[2])
end
return p