Jonas Kress (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/366260 )
Change subject: Follow up LexemeIdHtmlFormatter.php ...................................................................... Follow up LexemeIdHtmlFormatter.php Change-Id: Iaf469353c6945babf9022c021c2a85783bbdd974 --- M WikibaseLexeme.datatypes.php M src/PropertyType/LexemeIdHtmlFormatter.php 2 files changed, 18 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme refs/changes/60/366260/1 diff --git a/WikibaseLexeme.datatypes.php b/WikibaseLexeme.datatypes.php index 37720f8..8c08a74 100644 --- a/WikibaseLexeme.datatypes.php +++ b/WikibaseLexeme.datatypes.php @@ -20,7 +20,6 @@ use ValueFormatters\FormatterOptions; use Wikibase\Lexeme\DataModel\Lexeme; use Wikibase\Lexeme\PropertyType\FormIdFormatter; -use Wikibase\Lexeme\PropertyType\FormIdParser; use Wikibase\Lexeme\PropertyType\LexemeIdHtmlFormatter; use Wikibase\Lexeme\PropertyType\SenseIdFormatter; use Wikibase\Lib\SnakFormatter; @@ -37,7 +36,8 @@ if ( $format === SnakFormatter::FORMAT_HTML ) { return new LexemeIdHtmlFormatter( WikibaseRepo::getDefaultInstance()->getEntityLookup(), - WikibaseRepo::getDefaultInstance()->getEntityTitleLookup() + WikibaseRepo::getDefaultInstance()->getEntityTitleLookup(), + Language::factory( $options->getOption( 'lang' ) ) ); } diff --git a/src/PropertyType/LexemeIdHtmlFormatter.php b/src/PropertyType/LexemeIdHtmlFormatter.php index 521b242..1fd44be 100644 --- a/src/PropertyType/LexemeIdHtmlFormatter.php +++ b/src/PropertyType/LexemeIdHtmlFormatter.php @@ -37,11 +37,12 @@ public function __construct( EntityLookup $entityLookup, - EntityTitleLookup $entityTitleLookup + EntityTitleLookup $entityTitleLookup, + Language $language ) { $this->entityLookup = $entityLookup; $this->entityTitleLookup = $entityTitleLookup; - $this->language = Language::factory( 'en' ); + $this->language = $language; } /** @@ -78,9 +79,9 @@ $label = $this->buildLabel( $lexeme ); $attributes = [ - 'href' => $url + 'href' => $url, + 'title' => $this->buildTitle( $lexeme ) ]; - return Html::element( 'a', $attributes, $label ); } @@ -103,6 +104,13 @@ return $lexemeId->getSerialization() . $separator . $undefinedInfo; } + private function buildTitle( Lexeme $lexeme ) { + return $lexeme->getType().' '.wfMessage( + 'colon', + $lexeme->getId()->getSerialization() + ); + } + private function buildLabel( Lexeme $lexeme ) { $label = ''; @@ -112,11 +120,6 @@ } $label .= $this->language->commaList( $glossTexts ); - $label .= ' '; - $label .= wfMessage( - 'parentheses', - $lexeme->getId()->getSerialization() - ); $label .= ' '; /** @var Item $languageItem */ @@ -128,11 +131,11 @@ // 'noun in English' // TODO: Rethink way to present 'noun in English' - it will not look correct in Russian // because language word should be in the genitive which currently is not possible - $label .= wfMessage( - 'wikibase-lexeme-view-language-lexical-category', + $label .= wfMessage( 'wikibase-lexeme-view-language-lexical-category', [ - $lexicalCategoryItem->getLabels()->getByLanguage( $languageCode )->getText(), - $languageItem->getLabels()->getByLanguage( $languageCode )->getText() + $lexicalCategoryItem ? $lexicalCategoryItem->getLabels()->getByLanguage( + $languageCode )->getText() : null, + $languageItem ? $languageItem->getLabels()->getByLanguage( $languageCode )->getText() : null ] ); -- To view, visit https://gerrit.wikimedia.org/r/366260 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaf469353c6945babf9022c021c2a85783bbdd974 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseLexeme Gerrit-Branch: master Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Jakob <jakob.warkot...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits