Liangent has uploaded a new change for review.
https://gerrit.wikimedia.org/r/72751
Change subject: Allow mw.wikibase.label( ) to find labels written in variants
......................................................................
Allow mw.wikibase.label( ) to find labels written in variants
Some hacky way is used here...
Change-Id: Ib73d9090f2db481c5c3592f0eab17fa33d6cd1bc
---
M client/includes/WikibaseLibrary.php
1 file changed, 15 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/51/72751/1
diff --git a/client/includes/WikibaseLibrary.php
b/client/includes/WikibaseLibrary.php
index e49a876..ff1142d 100644
--- a/client/includes/WikibaseLibrary.php
+++ b/client/includes/WikibaseLibrary.php
@@ -28,6 +28,8 @@
use Wikibase\Client\WikibaseClient;
use Wikibase\Lib\Serializers\EntitySerializationOptions;
use Wikibase\Lib\Serializers\SerializerFactory;
+use Wikibase\LanguageFallbackChainFactory;
+use Wikibase\Utils;
class Scribunto_LuaWikibaseLibrary extends Scribunto_LuaLibraryBase {
@@ -76,6 +78,19 @@
$serializerFactory = new SerializerFactory();
$opt = new EntitySerializationOptions(
WikibaseClient::getDefaultInstance()->getEntityIdFormatter() );
+
+ // This is $wgContLang, not parser target language or anything
else.
+ // See Scribunto_LuaLanguageLibrary::getContLangCode().
+ global $wgContLang;
+
+ // See mw.wikibase.lua. This is the only way to inject values
into mw.wikibase.label( ),
+ // so any customized Lua modules can access labels of another
entity written in another variant,
+ // unless we give them the ability to getEntity() any entity by
specifying its ID, not just self.
+ $chain =
WikibaseClient::getDefaultInstance()->getLanguageFallbackChainFactory()->newFromLanguage(
+ $wgContLang,
LanguageFallbackChainFactory::FALLBACK_SELF |
LanguageFallbackChainFactory::FALLBACK_VARIANTS
+ );
+ $opt->setLanguages( Utils::getLanguageCodes() + array(
$wgContLang->getCode() => $chain ) );
+
$serializer = $serializerFactory->newSerializerForObject(
$entityObject, $opt );
try {
--
To view, visit https://gerrit.wikimedia.org/r/72751
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib73d9090f2db481c5c3592f0eab17fa33d6cd1bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Liangent <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits