From 497e61d0dcc5de9e4f692f27ce5a01f8ef8a2227 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Mon, 11 Nov 2024 09:36:42 +0800 Subject: [PATCH] Finish switching to Intuition A follow up from #62. Bug: T370133 --- src/Controller/UploadController.php | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Controller/UploadController.php b/src/Controller/UploadController.php index 7cadc6d..9208ca8 100644 --- a/src/Controller/UploadController.php +++ b/src/Controller/UploadController.php @@ -5,12 +5,12 @@ use DI\Container; use Exception; use GuzzleHttp\Psr7\LazyOpenStream; +use Krinkle\Intuition\Intuition; use Locale; use Mediawiki\Api\Guzzle\ClientFactory; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Routing\RouteParser; -use Wikimedia\SimpleI18n\I18nContext; use Wikisource\IaUpload\ApiClient\CommonsClient; use Wikisource\IaUpload\ApiClient\IaClient; use Wikisource\IaUpload\OAuth\MediaWikiOAuth; @@ -37,7 +37,7 @@ class UploadController { protected $routeParser; /** - * @var I18nContext + * @var Intuition */ protected $i18n; @@ -215,7 +215,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'set-all-fields' ), + 'error' => $this->i18n->msg( 'set-all-fields' ), ], $response ); } // Ensure that file name is less than or equal to 240 bytes. @@ -224,7 +224,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'invalid-length', [ $commonsName ] ), + 'error' => $this->i18n->msg( 'invalid-length', [ $commonsName ] ), ], $response ); } // Strip any trailing file extension. @@ -235,7 +235,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'invalid-commons-name', [ $commonsName ] ), + 'error' => $this->i18n->msg( 'invalid-commons-name', [ $commonsName ] ), ], $response ); } @@ -249,7 +249,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'no-found-on-ia', [ $link ] ), + 'error' => $this->i18n->msg( 'no-found-on-ia', [ $link ] ), ], $response ); } $iaId = $iaData['metadata']['identifier'][0]; @@ -264,7 +264,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'no-usable-files-found' ), + 'error' => $this->i18n->msg( 'no-usable-files-found' ), ], $response ); } @@ -276,16 +276,16 @@ public function fill( Request $request, Response $response ) { $sizeInMb = round( $iaData['files'][$jp2Filename]['size'] / ( 1024 * 1024 ) ); if ( $sizeInMb > $maxSizeInMb ) { $msgParams = [ $sizeInMb, $maxSizeInMb ]; - $warning = $this->i18n->message( 'zip-file-too-large', $msgParams ) - . ' ' . $this->i18n->message( 'watch-log' ); + $warning = $this->i18n->msg( 'zip-file-too-large', $msgParams ) + . ' ' . $this->i18n->msg( 'watch-log' ); } // Make sure there aren't too many pages. $maxPageCount = 900; if ( isset( $iaData['metadata']['imagecount'][0] ) && $iaData['metadata']['imagecount'][0] > $maxPageCount ) { $msgParams = [ $iaData['metadata']['imagecount'][0], $maxPageCount ]; - $warning = $this->i18n->message( 'too-many-pages', $msgParams ) - . ' ' . $this->i18n->message( 'watch-log' ); + $warning = $this->i18n->msg( 'too-many-pages', $msgParams ) + . ' ' . $this->i18n->msg( 'watch-log' ); } } @@ -297,7 +297,7 @@ public function fill( Request $request, Response $response ) { 'iaId' => $iaId, 'format' => $format, 'commonsName' => $commonsName, - 'error' => $this->i18n->message( 'already-on-commons', [ $link ] ), + 'error' => $this->i18n->msg( 'already-on-commons', [ $link ] ), ], $response ); } @@ -305,7 +305,7 @@ public function fill( Request $request, Response $response ) { $existingPage = $this->commonsClient->pageForIAItem( $iaId ); if ( $existingPage ) { $linkExisting = $this->commonsClient->getHtmlLink( $existingPage ); - $warning = $this->i18n->message( 'ia-identifier-exists', [ $iaId, $linkExisting ] ); + $warning = $this->i18n->msg( 'ia-identifier-exists', [ $iaId, $linkExisting ] ); } // Output the page. @@ -356,7 +356,7 @@ public function save( Request $request, Response $response ) { // Check again that the Commons file doesn't exist. if ( $this->commonsClient->pageExist( 'File:' . $jobInfo['fullCommonsName'] ) ) { $link = $this->commonsClient->getHtmlLink( 'File:' . $jobInfo['fullCommonsName'] ); - $jobInfo['error'] = $this->i18n->message( 'already-on-commons', [ $link ] ); + $jobInfo['error'] = $this->i18n->msg( 'already-on-commons', [ $link ] ); return $this->outputsFillTemplate( $jobInfo, $response ); } @@ -366,7 +366,7 @@ public function save( Request $request, Response $response ) { $link = '' . htmlspecialchars( $jobInfo['iaId'] ) . ''; - $jobInfo['error'] = $this->i18n->message( 'no-found-on-ia', [ $link ] ); + $jobInfo['error'] = $this->i18n->msg( 'no-found-on-ia', [ $link ] ); return $this->outputsFillTemplate( $jobInfo, $response ); } $jobInfo['iaId'] = $iaData['metadata']['identifier'][0]; @@ -408,7 +408,7 @@ public function save( Request $request, Response $response ) { if ( isset( $result['upload']['warnings']['duplicate'][0] ) ) { $dupeFile = $result['upload']['warnings']['duplicate'][0]; $dupeLink = $this->commonsClient->getHtmlLink( 'File:' . $dupeFile ); - $jobInfo['error'] = $this->i18n->message( 'duplicate-on-commons', [ $dupeLink ] ); + $jobInfo['error'] = $this->i18n->msg( 'duplicate-on-commons', [ $dupeLink ] ); return $this->outputsFillTemplate( $jobInfo, $response ); } } catch ( Exception $e ) { @@ -428,7 +428,7 @@ public function save( Request $request, Response $response ) { rmdir( $jobDirectory ); $fileLink = $this->commonsClient->getHtmlLink( 'File:' . $jobInfo['fullCommonsName'] ); return $this->outputsInitTemplate( [ - 'success' => $this->i18n->message( 'successfully-uploaded', [ $fileLink ] ), + 'success' => $this->i18n->msg( 'successfully-uploaded', [ $fileLink ] ), ], $response ); } } @@ -715,7 +715,7 @@ protected function parseAuthorParam( $data, &$notes ) { if ( $this->commonsClient->pageExist( "Creator:$creator" ) ) { return "{{Creator:$creator}}"; } else { - $notes[] = $this->i18n->message( 'creator-template-missing', [ $creator ] ); + $notes[] = $this->i18n->msg( 'creator-template-missing', [ $creator ] ); return $creator; } }