Adrian Lang has uploaded a new change for review.
https://gerrit.wikimedia.org/r/187355
Change subject: Introduce content language concept for SpecialNewEntity
......................................................................
Introduce content language concept for SpecialNewEntity
Bug: T86929
Change-Id: Icfd92988f56a00955b1f26132799d572b9e39d4e
---
M repo/includes/specials/SpecialNewEntity.php
1 file changed, 24 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/55/187355/1
diff --git a/repo/includes/specials/SpecialNewEntity.php
b/repo/includes/specials/SpecialNewEntity.php
index 9575dce..df8406d 100644
--- a/repo/includes/specials/SpecialNewEntity.php
+++ b/repo/includes/specials/SpecialNewEntity.php
@@ -41,6 +41,11 @@
protected $description = null;
/**
+ * @var Language
+ */
+ private $contentLanguage = null;
+
+ /**
* @var SummaryFormatter
*/
protected $summaryFormatter;
@@ -92,6 +97,8 @@
$out = $this->getOutput();
+ $uiLanguageCode = $this->getLanguage()->getCode();
+
if ( $this->getRequest()->wasPosted()
&& $this->getUser()->matchEditToken(
$this->getRequest()->getVal( 'token' ) ) ) {
@@ -102,7 +109,7 @@
if ( $status->isGood() ) {
$summary = new Summary( 'wbeditentity',
'create' );
- $summary->setLanguage(
$this->getLanguage()->getCode() );
+ $summary->setLanguage( $uiLanguageCode
);
$summary->addAutoSummaryArgs(
$this->label, $this->description );
$status = $this->saveEntity(
@@ -148,6 +155,7 @@
protected function prepareArguments() {
$this->label = $this->getRequest()->getVal( 'label', isset(
$this->parts[0] ) ? $this->parts[0] : '' );
$this->description = $this->getRequest()->getVal(
'description', isset( $this->parts[1] ) ? $this->parts[1] : '' );
+ $this->contentLanguage = Language::factory(
$this->getRequest()->getVal( 'lang', $this->getLanguage()->getCode() ) );
return true;
}
@@ -182,12 +190,12 @@
* @return Status
*/
protected function modifyEntity( Entity &$entity ) {
- $lang = $this->getLanguage()->getCode();
+ $contentLanguageCode = $this->contentLanguage->getCode();
if ( $this->label !== '' ) {
- $entity->setLabel( $lang, $this->label );
+ $entity->setLabel( $contentLanguageCode, $this->label );
}
if ( $this->description !== '' ) {
- $entity->setDescription( $lang, $this->description );
+ $entity->setDescription( $contentLanguageCode,
$this->description );
}
return \Status::newGood();
}
@@ -201,7 +209,12 @@
*/
protected function additionalFormElements() {
global $wgLang;
- return Html::element(
+ return
+ Html::hidden(
+ 'lang',
+ $this->contentLanguage->getCode()
+ )
+ . Html::element(
'label',
array(
'for' => 'wb-newentity-label',
@@ -217,11 +230,11 @@
'id' => 'wb-newentity-label',
'size' => 12,
'class' => 'wb-input',
- 'lang' => $wgLang->getCode(),
- 'dir' => $wgLang->getDir(),
+ 'lang' => $this->contentLanguage->getCode(),
+ 'dir' => $this->contentLanguage->getDir(),
'placeholder' => $this->msg(
'wikibase-label-edit-placeholder-language-aware',
- Language::fetchLanguageName(
$wgLang->getCode() )
+ Language::fetchLanguageName(
$this->contentLanguage->getCode() )
)->text(),
)
)
@@ -242,11 +255,11 @@
'id' => 'wb-newentity-description',
'size' => 36,
'class' => 'wb-input',
- 'lang' => $wgLang->getCode(),
- 'dir' => $wgLang->getDir(),
+ 'lang' => $this->contentLanguage->getCode(),
+ 'dir' => $this->contentLanguage->getDir(),
'placeholder' => $this->msg(
'wikibase-description-edit-placeholder-language-aware',
- Language::fetchLanguageName(
$wgLang->getCode() )
+ Language::fetchLanguageName(
$this->contentLanguage->getCode() )
)->text(),
)
)
--
To view, visit https://gerrit.wikimedia.org/r/187355
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfd92988f56a00955b1f26132799d572b9e39d4e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits