Daniel Kinzler has submitted this change and it was merged. Change subject: (#46125) Lua function label(id) that takes an ID and returns the label in the language of the client Wiki ......................................................................
(#46125) Lua function label(id) that takes an ID and returns the label in the language of the client Wiki Change-Id: Iecc7cf51ced432d25fb161f3639f791029979f7e --- M client/resources/mw.wikibase.lua 1 file changed, 13 insertions(+), 6 deletions(-) Approvals: Daniel Kinzler: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/client/resources/mw.wikibase.lua b/client/resources/mw.wikibase.lua index 533fb4d..7139ab8 100644 --- a/client/resources/mw.wikibase.lua +++ b/client/resources/mw.wikibase.lua @@ -26,16 +26,23 @@ local wikibase = {} function wikibase.setupInterface() - local title = require('mw.title') - local site = require('mw.site') local php = mw_interface mw_interface = nil - wikibase.getEntity = function() - id = php.getEntityId(tostring(title.getCurrentTitle().prefixedText)) - if (id == nil) then return nil end - entity = php.getEntity(id) + wikibase.getEntity = function () + local id = php.getEntityId( tostring( mw.title.getCurrentTitle().prefixedText ) ) + if id == nil then return nil end + local entity = php.getEntity( id ) return entity end + wikibase.label = function ( id ) + local code = mw.language.getContentLanguage():getCode() + if code == nil then return nil end + local entity = php.getEntity( id ) + if entity == nil then return nil end + local label = entity.labels[code] + if label == nil then return nil end + return label.value + end mw = mw or {} mw.wikibase = wikibase package.loaded['mw.wikibase'] = wikibase -- To view, visit https://gerrit.wikimedia.org/r/54647 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iecc7cf51ced432d25fb161f3639f791029979f7e Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jens Ohlig <jens.oh...@wikimedia.de> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Denny Vrandecic <denny.vrande...@wikimedia.de> Gerrit-Reviewer: Jens Ohlig <jens.oh...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits