jenkins-bot has submitted this change and it was merged. Change subject: Add {{WBREPONAME}} magic word ......................................................................
Add {{WBREPONAME}} magic word Bug: 45852 Change-Id: Ide94af740194788fff9f15b1878af961d5e0ce06 --- M client/WikibaseClient.hooks.php M client/WikibaseClient.i18n.magic.php M client/WikibaseClient.i18n.php M client/config/WikibaseClient.default.php M docs/options.wiki 5 files changed, 43 insertions(+), 16 deletions(-) Approvals: Hoo man: Looks good to me, approved WikidataJenkins: Verified jenkins-bot: Verified diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php index d92fab2..012b7d9 100644 --- a/client/WikibaseClient.hooks.php +++ b/client/WikibaseClient.hooks.php @@ -1,4 +1,5 @@ <?php + namespace Wikibase; use Action; @@ -6,6 +7,7 @@ use FormOptions; use IContextSource; use JobQueueGroup; +use Message; use MovePageForm; use OutputPage; use Parser; @@ -664,6 +666,8 @@ */ public static function onMagicWordwgVariableIDs( &$aCustomVariableIds ) { $aCustomVariableIds[] = 'noexternallanglinks'; + $aCustomVariableIds[] = 'wbreponame'; + return true; } @@ -671,8 +675,22 @@ * Apply the magic word. */ public static function onParserGetVariableValueSwitch( &$parser, &$cache, &$magicWordId, &$ret ) { - if( $magicWordId == 'noexternallanglinks' ) { + if ( $magicWordId == 'noexternallanglinks' ) { NoLangLinkHandler::handle( $parser, '*' ); + } elseif ( $magicWordId == 'wbreponame' ) { + // @todo factor out, with tests + $wikibaseClient = WikibaseClient::getDefaultInstance(); + $settings = $wikibaseClient->getSettings(); + $repoSiteName = $settings->getSetting( 'repoSiteName' ); + + $message = new Message( $repoSiteName ); + + if ( $message->exists() ) { + $lang = $parser->getTargetLanguage(); + $ret = $message->inLanguage( $lang )->parse(); + } else { + $ret = $repoSiteName; + } } return true; diff --git a/client/WikibaseClient.i18n.magic.php b/client/WikibaseClient.i18n.magic.php index 00e5be7..b95882f 100644 --- a/client/WikibaseClient.i18n.magic.php +++ b/client/WikibaseClient.i18n.magic.php @@ -14,6 +14,7 @@ $magicWords['en'] = array( 'noexternallanglinks' => array( 0, 'noexternallanglinks' ), 'property' => array( 0, 'property' ), + 'wbreponame' => array( 0, 'wbreponame' ), ); /** Arabic (العربية) */ @@ -148,4 +149,4 @@ $magicWords['zh-hant'] = array( 'noexternallanglinks' => array( 0, '隱藏跨語言連結' ), 'property' => array( 0, '屬性' ), -); \ No newline at end of file +); diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php index 8a6edb9..633bc86 100644 --- a/client/WikibaseClient.i18n.php +++ b/client/WikibaseClient.i18n.php @@ -20,17 +20,17 @@ */ $messages['en'] = array( 'wikibase-client-desc' => 'Client for the Wikibase extension', - 'specialpages-group-wikibaseclient' => 'Wikidata client', + 'specialpages-group-wikibaseclient' => '{{WBREPONAME}} client', 'tooltip-t-wikibase' => 'Link to connected data repository item', 'accesskey-t-wikibase' => 'g', - 'wikibase-after-page-move' => 'You may also [$1 update] the associated Wikidata item to maintain language links on moved page.', - 'wikibase-after-page-move-queued' => 'The [$1 Wikidata item] associated with this page will be automatically updated soon.', - 'wikibase-comment-add' => 'A Wikidata item has been created.', - 'wikibase-comment-remove' => 'Associated Wikidata item deleted. Language links removed.', - 'wikibase-comment-linked' => 'A Wikidata item has been linked to this page.', - 'wikibase-comment-unlink' => 'This page has been unlinked from Wikidata item. Language links removed.', - 'wikibase-comment-restore' => 'Associated Wikidata item undeleted. Language links restored.', - 'wikibase-comment-update' => 'Wikidata item changed', + 'wikibase-after-page-move' => 'You may also [$1 update] the associated {{WBREPONAME}} item to maintain language links on moved page.', + 'wikibase-after-page-move-queued' => 'The [$1 {{WBREPONAME}} item] associated with this page will be automatically updated soon.', + 'wikibase-comment-add' => 'A {{WBREPONAME}} item has been created.', + 'wikibase-comment-remove' => 'Associated {{WBREPONAME}} item deleted. Language links removed.', + 'wikibase-comment-linked' => 'A {{WBREPONAME}} item has been linked to this page.', + 'wikibase-comment-unlink' => 'This page has been unlinked from {{WBREPONAME}} item. Language links removed.', + 'wikibase-comment-restore' => 'Associated {{WBREPONAME}} item undeleted. Language links restored.', + 'wikibase-comment-update' => '{{WBREPONAME}} item changed', 'wikibase-comment-sitelink-add' => 'Language link added: $1', 'wikibase-comment-sitelink-change' => 'Language link changed from $1 to $2', 'wikibase-comment-sitelink-remove' => 'Language link removed: $1', @@ -54,13 +54,13 @@ 'wikibase-linkitem-success-link' => 'The pages have successfully been linked. You can find the item containing the links in our [$1 central data repository].', 'wikibase-property-notfound' => '$1 property not found.', 'wikibase-property-notsupportedyet' => 'Wikibase does not yet support property type for $1 property.', - 'wikibase-rc-hide-wikidata' => '$1 Wikidata', + 'wikibase-rc-hide-wikidata' => '$1 {{WBREPONAME}}', 'wikibase-rc-hide-wikidata-hide' => 'Hide', 'wikibase-rc-hide-wikidata-show' => 'Show', - 'wikibase-rc-show-wikidata-pref' => 'Show Wikidata edits in recent changes', + 'wikibase-rc-show-wikidata-pref' => 'Show {{WBREPONAME}} edits in recent changes', 'wikibase-rc-wikibase-edit-letter' => 'D', - 'wikibase-rc-wikibase-edit-title' => 'Wikidata edit', - 'wikibase-watchlist-show-changes-pref' => 'Show Wikidata edits in your watchlist', + 'wikibase-rc-wikibase-edit-title' => '{{WBREPONAME}} edit', + 'wikibase-watchlist-show-changes-pref' => 'Show {{WBREPONAME}} edits in your watchlist', 'wikibase-error-serialize-error' => 'Failed to serialize data.', 'wikibase-error-invalid-entity-id' => 'The ID entered is unknown to the system. Please use a valid entity ID.', 'special-unconnectedpages' => 'Pages not connected to items', @@ -71,7 +71,7 @@ 'wikibase-unconnectedpages-page-warning' => 'The page title could not be used for the query and is ignored.', 'wikibase-unconnectedpages-iwdata-label' => 'Only pages with interlanguage links', 'wikibase-unconnectedpages-format-row' => '($1 {{PLURAL:$1|interlanguage link|interlanguage links}} on the page)', - 'wikibase-pageinfo-entity-id' => 'Wikidata Item ID', + 'wikibase-pageinfo-entity-id' => '{{WBREPONAME}} item ID', 'wikibase-pageinfo-entity-id-none' => 'None', 'wikibase-property-render-error' => 'Failed to render property $1: $2' ); diff --git a/client/config/WikibaseClient.default.php b/client/config/WikibaseClient.default.php index 488b3c3..39df88e 100644 --- a/client/config/WikibaseClient.default.php +++ b/client/config/WikibaseClient.default.php @@ -179,6 +179,13 @@ return defined( 'WB_VERSION' ); }; + $defaults['repoSiteName'] = function ( SettingsArray $settings ) { + // This uses $wgSitename if this wiki is the repo. Otherwise, set this to + // either an i18n message key and the message will be used, if it exists. + // If repo site name does not need translation, then set this as a string. + return $settings->getSetting( 'thisWikiIsTheRepo' ) ? $GLOBALS['wgSitename'] : 'Wikidata'; + }; + $defaults['repoUrl'] = function ( SettingsArray $settings ) { // use $wgServer if this wiki is the repo, otherwise default to wikidata.org return $settings->getSetting( 'thisWikiIsTheRepo' ) ? $GLOBALS['wgServer'] : '//www.wikidata.org'; diff --git a/docs/options.wiki b/docs/options.wiki index 5c5fc9c..4b11d1d 100644 --- a/docs/options.wiki +++ b/docs/options.wiki @@ -82,6 +82,7 @@ ;siteLocalID: This site's local ID resp. language code (e.g. <code>'it'</code>). Default: <code>$wgLanguageCode</code>. '''Note:''' this setting will be removed once we can take this information from the sites table. ;siteGroup: This site's site group (e.g. <code>'wikipedia'</code> or <code>'wikivoyage'</code>) as used in the sites table. The setting is optional and falls back to site store lookup. For performance reasons, it may be desireable to set this explicitly to avoid lookups. ;repoSiteId: Site id of connected repository wiki. Default is to assume client and repo, so this setting defaults to siteGlobalID. +;repoSiteName: Site name of the connected repository wiki. Default is to assume client and repo are same wiki, so defaults to global $wgSitename setting. If not the same wiki, defaults to 'Wikidata'. This setting can also be set to an i18n message key and will be handled as a message, if the message key exists so that the repo site name can be translatable. ;repoDatabase: The logical name of the repository database, in a form that LBFactory can understand. If not <code>null</code>, the client wiki will access the repository's database directly, instead of locally caching information received via change notifications. Default: <node>null</code>. Note that <code>false</code> would mean "this wiki's database"! '''Note:''' this is currently required to be not <code>null</code>, since local caching is not fully implemented. // default for repo items in main namespace ;repoNamespaces: An array telling the client wiki which namespaces on the repository are used for which kind of entity. This is given as an associative array mapping entity type IDs such as Item::ENTITY_TYPE, to namespace names. This information is used when constructing links to entities on the repository. Default: -- To view, visit https://gerrit.wikimedia.org/r/116099 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ide94af740194788fff9f15b1878af961d5e0ce06 Gerrit-PatchSet: 14 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits