diff --git a/app/Exceptions/OrderNotModifiableException.php b/app/Exceptions/OrderNotModifiableException.php index f24bdca3617..cf620ada977 100644 --- a/app/Exceptions/OrderNotModifiableException.php +++ b/app/Exceptions/OrderNotModifiableException.php @@ -19,10 +19,10 @@ class OrderNotModifiableException extends Exception public function __construct(Order $order) { $key = "store.order.not_modifiable_exception.{$order->status}"; - $trans = trans($key); + $trans = osu_trans($key); parent::__construct( - $trans === $key ? trans('store.order.not_modifiable_exception.default') : $trans + $trans === $key ? osu_trans('store.order.not_modifiable_exception.default') : $trans ); $this->order = $order; diff --git a/app/Exceptions/UserVerificationException.php b/app/Exceptions/UserVerificationException.php index 466509f4809..0e5397057ec 100644 --- a/app/Exceptions/UserVerificationException.php +++ b/app/Exceptions/UserVerificationException.php @@ -17,7 +17,7 @@ public function __construct(string $reasonKey, bool $shouldReissue) $this->reasonKey = $reasonKey; $this->shouldReissue = $shouldReissue; - $message = trans("user_verification.errors.{$reasonKey}"); + $message = osu_trans("user_verification.errors.{$reasonKey}"); parent::__construct($message); } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index feaaf691cf7..3e3319f8858 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -29,7 +29,7 @@ public function __construct() $this->middleware(function ($request, $next) { if (Auth::check() && Auth::user()->isSilenced()) { - return abort(403, trans('authorization.silenced')); + return abort(403, osu_trans('authorization.silenced')); } return $next($request); @@ -75,7 +75,7 @@ public function avatar() public function cover() { if (Request::hasFile('cover_file') && !Auth::user()->osu_subscriber) { - return error_popup(trans('errors.supporter_only')); + return error_popup(osu_trans('errors.supporter_only')); } try { diff --git a/app/Http/Controllers/ArtistsController.php b/app/Http/Controllers/ArtistsController.php index 2332ca7d438..8fd591302c1 100644 --- a/app/Http/Controllers/ArtistsController.php +++ b/app/Http/Controllers/ArtistsController.php @@ -61,7 +61,7 @@ public function show($id) if ($artist->user_id) { $links[] = [ - 'title' => trans('artist.links.osu'), + 'title' => osu_trans('artist.links.osu'), 'url' => route('users.show', $artist->user_id), 'icon' => 'fas fa-user', 'class' => 'osu', @@ -70,7 +70,7 @@ public function show($id) if ($artist->website) { $links[] = [ - 'title' => trans('artist.links.site'), + 'title' => osu_trans('artist.links.site'), 'url' => $artist->website, 'icon' => 'fas fa-link', 'class' => 'website', diff --git a/app/Http/Controllers/BeatmapDiscussionsController.php b/app/Http/Controllers/BeatmapDiscussionsController.php index 1248bf0e93f..ba2e70d35aa 100644 --- a/app/Http/Controllers/BeatmapDiscussionsController.php +++ b/app/Http/Controllers/BeatmapDiscussionsController.php @@ -172,7 +172,7 @@ public function vote($id) if ($discussion->vote($params)) { return $discussion->beatmapset->defaultDiscussionJson(); } else { - return error_popup(trans('beatmaps.discussion-votes.update.error')); + return error_popup(osu_trans('beatmaps.discussion-votes.update.error')); } } } diff --git a/app/Http/Controllers/BeatmapsController.php b/app/Http/Controllers/BeatmapsController.php index 777474c20bc..7c58bb7ec24 100644 --- a/app/Http/Controllers/BeatmapsController.php +++ b/app/Http/Controllers/BeatmapsController.php @@ -81,7 +81,7 @@ public function scores($id) try { if ($type !== 'global' || !empty($mods)) { if ($currentUser === null || !$currentUser->isSupporter()) { - throw new ScoreRetrievalException(trans('errors.supporter_only')); + throw new ScoreRetrievalException(osu_trans('errors.supporter_only')); } } diff --git a/app/Http/Controllers/Beatmapsets/FavouritesController.php b/app/Http/Controllers/Beatmapsets/FavouritesController.php index c94b26260a4..c23cc1018d6 100644 --- a/app/Http/Controllers/Beatmapsets/FavouritesController.php +++ b/app/Http/Controllers/Beatmapsets/FavouritesController.php @@ -26,7 +26,7 @@ public function store($beatmapsetId) switch (request('action')) { case 'favourite': if ($user->favouriteBeatmapsets()->count() >= $user->beatmapsetFavouriteAllowance()) { - return error_popup(trans('beatmapsets.show.favourites.limit_reached')); + return error_popup(osu_trans('beatmapsets.show.favourites.limit_reached')); } $beatmapset->favourite($user); break; diff --git a/app/Http/Controllers/BeatmapsetsController.php b/app/Http/Controllers/BeatmapsetsController.php index d7175878532..392a9f1b6fe 100644 --- a/app/Http/Controllers/BeatmapsetsController.php +++ b/app/Http/Controllers/BeatmapsetsController.php @@ -164,7 +164,7 @@ public function download($id) ->count(); if ($recentlyDownloaded > Auth::user()->beatmapsetDownloadAllowance()) { - abort(429, trans('beatmapsets.download.limit_exceeded')); + abort(429, osu_trans('beatmapsets.download.limit_exceeded')); } $noVideo = get_bool(Request::input('noVideo', false)); diff --git a/app/Http/Controllers/BlocksController.php b/app/Http/Controllers/BlocksController.php index 70a27ebd1c6..c5d3f33ccf9 100644 --- a/app/Http/Controllers/BlocksController.php +++ b/app/Http/Controllers/BlocksController.php @@ -32,7 +32,7 @@ public function store() $currentUser = Auth::user(); if ($currentUser->blocks()->count() >= $currentUser->maxBlocks()) { - return error_popup(trans('users.blocks.too_many')); + return error_popup(osu_trans('users.blocks.too_many')); } $targetId = get_int(Request::input('target')); @@ -78,7 +78,7 @@ public function destroy($id) ->first(); if (!$block) { - abort(404, trans('users.blocks.not_blocked')); + abort(404, osu_trans('users.blocks.not_blocked')); } $user->blocks()->detach($block); diff --git a/app/Http/Controllers/FallbackController.php b/app/Http/Controllers/FallbackController.php index 4cf0f71cc8a..bd1423f3c30 100644 --- a/app/Http/Controllers/FallbackController.php +++ b/app/Http/Controllers/FallbackController.php @@ -23,7 +23,7 @@ public function index() app('route-section')->setError(404); if (is_json_request()) { - return error_popup(trans('errors.missing_route'), 404); + return error_popup(osu_trans('errors.missing_route'), 404); } return ext_view('layout.error', ['statusCode' => 404], 'html', 404); diff --git a/app/Http/Controllers/FriendsController.php b/app/Http/Controllers/FriendsController.php index f2bc0f67622..97bde1f84db 100644 --- a/app/Http/Controllers/FriendsController.php +++ b/app/Http/Controllers/FriendsController.php @@ -65,7 +65,7 @@ public function store() $friends = $currentUser->friends(); // don't fetch (avoids potentially instantiating 500+ friend objects) if ($friends->count() >= $currentUser->maxFriends()) { - return error_popup(trans('friends.too_many')); + return error_popup(osu_trans('friends.too_many')); } $targetId = get_int(Request::input('target')); diff --git a/app/Http/Controllers/NewsController.php b/app/Http/Controllers/NewsController.php index a80755e89ca..63881ce8e3c 100644 --- a/app/Http/Controllers/NewsController.php +++ b/app/Http/Controllers/NewsController.php @@ -201,7 +201,7 @@ public function store() NewsPost::syncAll(); - return ['message' => trans('news.store.ok')]; + return ['message' => osu_trans('news.store.ok')]; } public function update($id) @@ -210,7 +210,7 @@ public function update($id) NewsPost::findOrFail($id)->sync(true); - return ['message' => trans('news.update.ok')]; + return ['message' => osu_trans('news.update.ok')]; } private function sidebarMeta($post) diff --git a/app/Http/Controllers/OAuth/ClientsController.php b/app/Http/Controllers/OAuth/ClientsController.php index 64b397453db..2042f986b09 100644 --- a/app/Http/Controllers/OAuth/ClientsController.php +++ b/app/Http/Controllers/OAuth/ClientsController.php @@ -36,7 +36,7 @@ public function resetSecret($clientId) $client = auth()->user()->oauthClients()->findOrFail($clientId); if (!$client->resetSecret()) { - return error_popup(trans('oauth.client.reset_failed')); + return error_popup(osu_trans('oauth.client.reset_failed')); } return json_item($client, 'OAuth\Client', ['redirect', 'secret']); diff --git a/app/Http/Controllers/Passport/AuthorizationController.php b/app/Http/Controllers/Passport/AuthorizationController.php index 805c38ba3df..fe3b9f582ab 100644 --- a/app/Http/Controllers/Passport/AuthorizationController.php +++ b/app/Http/Controllers/Passport/AuthorizationController.php @@ -37,7 +37,7 @@ public function authorize( ) { $redirectUri = presence(trim($request['redirect_uri'])); - abort_if($redirectUri === null, 400, trans('model_validation.required', ['attribute' => 'redirect_uri'])); + abort_if($redirectUri === null, 400, osu_trans('model_validation.required', ['attribute' => 'redirect_uri'])); if (!auth()->check()) { // Breaks when url contains hash ("#"). diff --git a/app/Http/Controllers/PasswordResetController.php b/app/Http/Controllers/PasswordResetController.php index 1af6f13623a..da4c1fb71b8 100644 --- a/app/Http/Controllers/PasswordResetController.php +++ b/app/Http/Controllers/PasswordResetController.php @@ -43,7 +43,7 @@ public function create() $error = $this->issue(Request::input('username')); if ($error === null) { - return ['message' => trans('password_reset.notice.sent')]; + return ['message' => osu_trans('password_reset.notice.sent')]; } else { return response(['form_error' => [ 'username' => [$error], @@ -67,7 +67,7 @@ public function update() if (!present($inputKey)) { return response(['form_error' => [ - 'key' => [trans('password_reset.error.missing_key')], + 'key' => [osu_trans('password_reset.error.missing_key')], ]], 422); } @@ -82,7 +82,7 @@ public function update() Session::put('password_reset.tries', $tries); return response(['form_error' => [ - 'key' => [trans('password_reset.error.wrong_key')], + 'key' => [osu_trans('password_reset.error.wrong_key')], ]], 422); } @@ -95,7 +95,7 @@ public function update() UserAccountHistory::logUserResetPassword($user); - return ['message' => trans('password_reset.notice.saved')]; + return ['message' => osu_trans('password_reset.notice.saved')]; } else { return response(['form_error' => [ 'user' => $user->validationErrors()->all(), @@ -113,15 +113,15 @@ private function issue($username) $user = User::findForLogin($username, true); if ($user === null) { - return trans('password_reset.error.user_not_found'); + return osu_trans('password_reset.error.user_not_found'); } if (!present($user->user_email)) { - return trans('password_reset.error.contact_support'); + return osu_trans('password_reset.error.contact_support'); } if ($user->isPrivileged() && $user->user_password !== '') { - return trans('password_reset.error.is_privileged'); + return osu_trans('password_reset.error.is_privileged'); } $session = [ @@ -144,6 +144,6 @@ private function restart($reasonKey) { $this->clear(); - return ['message' => trans("password_reset.restart.{$reasonKey}")]; + return ['message' => osu_trans("password_reset.restart.{$reasonKey}")]; } } diff --git a/app/Http/Controllers/Payments/PaypalController.php b/app/Http/Controllers/Payments/PaypalController.php index 819b812274b..e654bccb1ef 100644 --- a/app/Http/Controllers/Payments/PaypalController.php +++ b/app/Http/Controllers/Payments/PaypalController.php @@ -85,7 +85,7 @@ public function declined() (new OrderCheckout($order, Order::PROVIDER_PAYPAL))->failCheckout(); - return $this->setAndRedirectCheckoutError($order, trans('store.checkout.declined')); + return $this->setAndRedirectCheckoutError($order, osu_trans('store.checkout.declined')); } // Called by Paypal. @@ -126,6 +126,6 @@ private function userErrorMessage($e) $key = 'paypal/errors.unknown'; } - return trans($key); + return osu_trans($key); } } diff --git a/app/Http/Controllers/SessionsController.php b/app/Http/Controllers/SessionsController.php index abb88645b1a..ddab5a2ba37 100644 --- a/app/Http/Controllers/SessionsController.php +++ b/app/Http/Controllers/SessionsController.php @@ -58,7 +58,7 @@ public function store() DatadogLoginAttempt::log('invalid_captcha'); } - return $this->triggerCaptcha(trans('users.login.invalid_captcha'), 422); + return $this->triggerCaptcha(osu_trans('users.login.invalid_captcha'), 422); } } @@ -67,7 +67,7 @@ public function store() $user = User::findForLogin($username); if ($user === null && strpos($username, '@') !== false && !config('osu.user.allow_email_login')) { - $authError = trans('users.login.email_login_disabled'); + $authError = osu_trans('users.login.email_login_disabled'); } else { $authError = User::attemptLogin($user, $password, $ip); } diff --git a/app/Http/Controllers/Store/CheckoutController.php b/app/Http/Controllers/Store/CheckoutController.php index f7c5cad3ec8..2f743277adb 100644 --- a/app/Http/Controllers/Store/CheckoutController.php +++ b/app/Http/Controllers/Store/CheckoutController.php @@ -67,7 +67,7 @@ public function store() if (!empty($validationErrors)) { return $this->setAndRedirectCheckoutError( $order, - trans('store.checkout.cart_problems'), + osu_trans('store.checkout.cart_problems'), $validationErrors ); } diff --git a/app/Http/Controllers/Store/NotificationRequestsController.php b/app/Http/Controllers/Store/NotificationRequestsController.php index f52f1ff8c2d..0c774f2705d 100644 --- a/app/Http/Controllers/Store/NotificationRequestsController.php +++ b/app/Http/Controllers/Store/NotificationRequestsController.php @@ -26,7 +26,7 @@ public function store($productId) $product = Product::findOrFail($productId); if ($product->inStock()) { - return error_popup(trans('store.product.notification_in_stock')); + return error_popup(osu_trans('store.product.notification_in_stock')); } try { diff --git a/app/Http/Middleware/CheckUserBanStatus.php b/app/Http/Middleware/CheckUserBanStatus.php index bebf1fb9f5d..d88bde79280 100644 --- a/app/Http/Middleware/CheckUserBanStatus.php +++ b/app/Http/Middleware/CheckUserBanStatus.php @@ -46,7 +46,7 @@ public function handle($request, Closure $next) logout(); if (is_api_request()) { - abort(403, trans('users.disabled.title')); + abort(403, osu_trans('users.disabled.title')); } else { return ujs_redirect(route('users.disabled')); } diff --git a/app/Http/Middleware/CheckUserRestricted.php b/app/Http/Middleware/CheckUserRestricted.php index 2ae07032911..7aa29164f79 100644 --- a/app/Http/Middleware/CheckUserRestricted.php +++ b/app/Http/Middleware/CheckUserRestricted.php @@ -40,7 +40,7 @@ public function __construct(Guard $auth) public function handle($request, Closure $next) { if ($this->auth->check() && $this->auth->user()->isRestricted()) { - return error_popup(trans('errors.no_restricted_access')); + return error_popup(osu_trans('errors.no_restricted_access')); } return $next($request); diff --git a/app/Libraries/AuthorizationResult.php b/app/Libraries/AuthorizationResult.php index 2092588114e..6a8e0a1b3ac 100644 --- a/app/Libraries/AuthorizationResult.php +++ b/app/Libraries/AuthorizationResult.php @@ -49,7 +49,7 @@ public function message() return; } - return trans('authorization.'.$this->rawMessage()); + return osu_trans('authorization.'.$this->rawMessage()); } public function ensureCan() diff --git a/app/Libraries/BeatmapsetDiscussionReview.php b/app/Libraries/BeatmapsetDiscussionReview.php index 2e2195a56e4..3f1d9e19234 100644 --- a/app/Libraries/BeatmapsetDiscussionReview.php +++ b/app/Libraries/BeatmapsetDiscussionReview.php @@ -30,7 +30,7 @@ public static function config() public static function create(Beatmapset $beatmapset, array $document, User $user) { if (empty($document)) { - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_document')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_document')); } $priorOpenProblemCount = self::getOpenProblemCount($beatmapset); @@ -44,12 +44,12 @@ public static function create(Beatmapset $beatmapset, array $document, User $use $blockCount = 0; foreach ($document as $block) { if (!isset($block['type'])) { - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_block_type')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_block_type')); } $message = get_string($block['text'] ?? null); if ($message === null) { - throw new InvariantException(trans('beatmap_discussions.review.validation.missing_text')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.missing_text')); } switch ($block['type']) { @@ -74,7 +74,7 @@ public static function create(Beatmapset $beatmapset, array $document, User $use case 'paragraph': if (mb_strlen($block['text']) > static::BLOCK_TEXT_LENGTH_LIMIT) { - throw new InvariantException(trans('beatmap_discussions.review.validation.block_too_large', ['limit' => static::BLOCK_TEXT_LENGTH_LIMIT])); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.block_too_large', ['limit' => static::BLOCK_TEXT_LENGTH_LIMIT])); } $output[] = [ 'type' => 'paragraph', @@ -84,19 +84,19 @@ public static function create(Beatmapset $beatmapset, array $document, User $use default: // invalid block type - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_block_type')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_block_type')); } $blockCount++; } $minIssues = config('osu.beatmapset.discussion_review_min_issues'); if (empty($childIds) || count($childIds) < $minIssues) { - throw new InvariantException(trans_choice('beatmap_discussions.review.validation.minimum_issues', $minIssues)); + throw new InvariantException(osu_trans_choice('beatmap_discussions.review.validation.minimum_issues', $minIssues)); } $maxBlocks = config('osu.beatmapset.discussion_review_max_blocks'); if ($blockCount > $maxBlocks) { - throw new InvariantException(trans_choice('beatmap_discussions.review.validation.too_many_blocks', $maxBlocks)); + throw new InvariantException(osu_trans_choice('beatmap_discussions.review.validation.too_many_blocks', $maxBlocks)); } $review = self::createPost( @@ -130,7 +130,7 @@ public static function create(Beatmapset $beatmapset, array $document, User $use public static function update(BeatmapDiscussion $discussion, array $document, User $user) { if (empty($document)) { - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_document')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_document')); } $beatmapset = Beatmapset::findOrFail($discussion->beatmapset_id); // handle deleted beatmapsets @@ -148,14 +148,14 @@ public static function update(BeatmapDiscussion $discussion, array $document, Us foreach ($document as $block) { if (!isset($block['type'])) { - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_block_type')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_block_type')); } $message = get_string($block['text'] ?? null); if ($message === null) { // skip empty message check if this is an existing embed if ($block['type'] !== 'embed' || !isset($block['discussion_id'])) { - throw new InvariantException(trans('beatmap_discussions.review.validation.missing_text')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.missing_text')); } } @@ -189,7 +189,7 @@ public static function update(BeatmapDiscussion $discussion, array $document, Us case 'paragraph': if (mb_strlen($block['text']) > static::BLOCK_TEXT_LENGTH_LIMIT) { - throw new InvariantException(trans('beatmap_discussions.review.validation.block_too_large', ['limit' => static::BLOCK_TEXT_LENGTH_LIMIT])); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.block_too_large', ['limit' => static::BLOCK_TEXT_LENGTH_LIMIT])); } $output[] = [ 'type' => 'paragraph', @@ -199,25 +199,25 @@ public static function update(BeatmapDiscussion $discussion, array $document, Us default: // invalid block type - throw new InvariantException(trans('beatmap_discussions.review.validation.invalid_block_type')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.invalid_block_type')); } $blockCount++; } $minIssues = config('osu.beatmapset.discussion_review_min_issues'); if (empty($childIds) || count($childIds) < $minIssues) { - throw new InvariantException(trans_choice('beatmap_discussions.review.validation.minimum_issues', $minIssues)); + throw new InvariantException(osu_trans_choice('beatmap_discussions.review.validation.minimum_issues', $minIssues)); } $maxBlocks = config('osu.beatmapset.discussion_review_max_blocks'); if ($blockCount > $maxBlocks) { - throw new InvariantException(trans_choice('beatmap_discussions.review.validation.too_many_blocks', $maxBlocks)); + throw new InvariantException(osu_trans_choice('beatmap_discussions.review.validation.too_many_blocks', $maxBlocks)); } // ensure all referenced embeds belong to this discussion $externalEmbeds = BeatmapDiscussion::whereIn('id', $childIds)->where('parent_id', '<>', $discussion->getKey())->count(); if ($externalEmbeds > 0) { - throw new InvariantException(trans('beatmap_discussions.review.validation.external_references')); + throw new InvariantException(osu_trans('beatmap_discussions.review.validation.external_references')); } // update the review post diff --git a/app/Libraries/ChangeUsername.php b/app/Libraries/ChangeUsername.php index 4caea36efa2..5f78384b058 100644 --- a/app/Libraries/ChangeUsername.php +++ b/app/Libraries/ChangeUsername.php @@ -25,10 +25,10 @@ public static function requireSupportedMessage() { $link = link_to( route('support-the-game'), - trans('model_validation.user.change_username.supporter_required.link_text') + osu_trans('model_validation.user.change_username.supporter_required.link_text') ); - return trans('model_validation.user.change_username.supporter_required._', ['link' => $link]); + return osu_trans('model_validation.user.change_username.supporter_required._', ['link' => $link]); } public function __construct(User $user, string $newUsername, string $type = 'paid') diff --git a/app/Libraries/ImageProcessor.php b/app/Libraries/ImageProcessor.php index d07d640c3db..bc5b0df9df7 100644 --- a/app/Libraries/ImageProcessor.php +++ b/app/Libraries/ImageProcessor.php @@ -33,15 +33,15 @@ public function __construct($inputPath, $targetDim, $targetFileSize) public function basicCheck() { if ($this->inputFileSize > $this->hardMaxFileSize) { - throw new ImageProcessorException(trans('users.show.edit.cover.upload.too_large')); + throw new ImageProcessorException(osu_trans('users.show.edit.cover.upload.too_large')); } if ($this->inputDim === null || !in_array($this->inputDim[2], $this->allowedTypes, true)) { - throw new ImageProcessorException(trans('users.show.edit.cover.upload.unsupported_format')); + throw new ImageProcessorException(osu_trans('users.show.edit.cover.upload.unsupported_format')); } if ($this->inputDim[0] > $this->hardMaxDim[0] || $this->inputDim[1] > $this->hardMaxDim[1]) { - throw new ImageProcessorException(trans('users.show.edit.cover.upload.too_large')); + throw new ImageProcessorException(osu_trans('users.show.edit.cover.upload.too_large')); } } @@ -75,7 +75,7 @@ public function process() $inputImage = open_image($this->inputPath, $this->inputDim); if ($inputImage === null) { - throw new ImageProcessorException(trans('users.show.edit.cover.upload.broken_file')); + throw new ImageProcessorException(osu_trans('users.show.edit.cover.upload.broken_file')); } if ( diff --git a/app/Libraries/OrderCheckout.php b/app/Libraries/OrderCheckout.php index 0f18ec9f1ed..1146799204c 100644 --- a/app/Libraries/OrderCheckout.php +++ b/app/Libraries/OrderCheckout.php @@ -184,19 +184,19 @@ public function validate() // Checkout process level validations, should not be part of OrderItem validation. if ($item->product === null || !$item->product->isAvailable()) { - $messages[] = trans('model_validation/store/product.not_available'); + $messages[] = osu_trans('model_validation/store/product.not_available'); } if (!$item->product->inStock($item->quantity)) { - $messages[] = trans('model_validation/store/product.insufficient_stock'); + $messages[] = osu_trans('model_validation/store/product.insufficient_stock'); } if ($item->quantity > $item->product->max_quantity) { - $messages[] = trans('model_validation/store/product.too_many', ['count' => $item->product->max_quantity]); + $messages[] = osu_trans('model_validation/store/product.too_many', ['count' => $item->product->max_quantity]); } if ($shouldShopify && !$item->product->isShopify()) { - $messages[] = trans('model_validation/store/product.must_separate'); + $messages[] = osu_trans('model_validation/store/product.must_separate'); } $customClass = $item->getCustomClassInstance(); diff --git a/app/Libraries/Search/BeatmapsetSearchRequestParams.php b/app/Libraries/Search/BeatmapsetSearchRequestParams.php index 07c1deeaafd..711687b97f6 100644 --- a/app/Libraries/Search/BeatmapsetSearchRequestParams.php +++ b/app/Libraries/Search/BeatmapsetSearchRequestParams.php @@ -121,9 +121,9 @@ public static function getAvailableFilters() $languages = Language::listing(); $genres = Genre::listing(); - $modes = [['id' => null, 'name' => trans('beatmaps.mode.any')]]; + $modes = [['id' => null, 'name' => osu_trans('beatmaps.mode.any')]]; foreach (Beatmap::MODES as $name => $id) { - $modes[] = ['id' => $id, 'name' => trans("beatmaps.mode.{$name}")]; + $modes[] = ['id' => $id, 'name' => osu_trans("beatmaps.mode.{$name}")]; } $extras = []; @@ -133,28 +133,28 @@ public static function getAvailableFilters() $statuses = []; foreach (static::AVAILABLE_EXTRAS as $id) { - $extras[] = ['id' => $id, 'name' => trans("beatmaps.extra.{$id}")]; + $extras[] = ['id' => $id, 'name' => osu_trans("beatmaps.extra.{$id}")]; } foreach (static::AVAILABLE_GENERAL as $id) { - $general[] = ['id' => $id, 'name' => trans("beatmaps.general.{$id}")]; + $general[] = ['id' => $id, 'name' => osu_trans("beatmaps.general.{$id}")]; } foreach (static::AVAILABLE_PLAYED as $id) { - $played[] = ['id' => $id, 'name' => trans("beatmaps.played.{$id}")]; + $played[] = ['id' => $id, 'name' => osu_trans("beatmaps.played.{$id}")]; } foreach (static::AVAILABLE_RANKS as $id) { - $ranks[] = ['id' => $id, 'name' => trans("beatmaps.rank.{$id}")]; + $ranks[] = ['id' => $id, 'name' => osu_trans("beatmaps.rank.{$id}")]; } foreach (static::AVAILABLE_STATUSES as $id) { - $statuses[] = ['id' => $id, 'name' => trans("beatmaps.status.{$id}")]; + $statuses[] = ['id' => $id, 'name' => osu_trans("beatmaps.status.{$id}")]; } $nsfw = [ - ['id' => false, 'name' => trans('beatmaps.nsfw.exclude')], - ['id' => true, 'name' => trans('beatmaps.nsfw.include')], + ['id' => false, 'name' => osu_trans('beatmaps.nsfw.exclude')], + ['id' => true, 'name' => osu_trans('beatmaps.nsfw.include')], ]; return compact('extras', 'general', 'genres', 'languages', 'modes', 'nsfw', 'played', 'ranks', 'statuses'); diff --git a/app/Libraries/UserVerification.php b/app/Libraries/UserVerification.php index 6c389f09603..dbd68e4ca22 100644 --- a/app/Libraries/UserVerification.php +++ b/app/Libraries/UserVerification.php @@ -128,7 +128,7 @@ public function reissue() $this->issue(); - return response(['message' => trans('user_verification.errors.reissued')], 200); + return response(['message' => osu_trans('user_verification.errors.reissued')], 200); } public function verify() diff --git a/app/Libraries/UsernameValidation.php b/app/Libraries/UsernameValidation.php index 57a8e272027..d9de34a490e 100644 --- a/app/Libraries/UsernameValidation.php +++ b/app/Libraries/UsernameValidation.php @@ -28,13 +28,13 @@ public static function validateAvailability(string $username): ValidationErrors $errors->add( 'username', '.username_available_in', - ['duration' => trans_choice('common.count.days', $remaining->days + 1)] + ['duration' => osu_trans_choice('common.count.days', $remaining->days + 1)] ); } elseif ($remaining->h > 0) { $errors->add( 'username', '.username_available_in', - ['duration' => trans_choice('common.count.hours', $remaining->h + 1)] + ['duration' => osu_trans_choice('common.count.hours', $remaining->h + 1)] ); } else { $errors->add('username', '.username_available_soon'); diff --git a/app/Libraries/ValidationErrors.php b/app/Libraries/ValidationErrors.php index 3e35bc16f16..180f4e33b33 100644 --- a/app/Libraries/ValidationErrors.php +++ b/app/Libraries/ValidationErrors.php @@ -29,9 +29,9 @@ public function add($column, $rawMessage, $params = null): self $rawMessage = $this->keyBase.$rawMessage; $attributeKey = $this->keyBase.$this->prefix.'.attributes.'.$column; - $params['attribute'] = Lang::has($attributeKey) ? trans($attributeKey) : $column; + $params['attribute'] = Lang::has($attributeKey) ? osu_trans($attributeKey) : $column; - $this->errors[$column][] = trans($rawMessage, $params); + $this->errors[$column][] = osu_trans($rawMessage, $params); return $this; } diff --git a/app/Mail/BeatmapsetUpdateNotice.php b/app/Mail/BeatmapsetUpdateNotice.php index 6f661e4d5bc..5f6e17eff8c 100644 --- a/app/Mail/BeatmapsetUpdateNotice.php +++ b/app/Mail/BeatmapsetUpdateNotice.php @@ -48,7 +48,7 @@ public function build() return $this ->text('emails.beatmapset.update_notice') - ->subject(trans('mail.beatmapset_update_notice.subject', [ + ->subject(osu_trans('mail.beatmapset_update_notice.subject', [ 'title' => $beatmapset->getDisplayTitle($user), ])) ->with(compact('beatmapset', 'user')); diff --git a/app/Mail/DonationThanks.php b/app/Mail/DonationThanks.php index 7438ea99c3d..50d1752c37c 100644 --- a/app/Mail/DonationThanks.php +++ b/app/Mail/DonationThanks.php @@ -48,6 +48,6 @@ public function build() config('store.mail.donation_thanks.sender_address'), config('store.mail.donation_thanks.sender_name') ) - ->subject(trans('mail.donation_thanks.subject')); + ->subject(osu_trans('mail.donation_thanks.subject')); } } diff --git a/app/Mail/ForumNewReply.php b/app/Mail/ForumNewReply.php index 638d1bb899e..1002453ef9c 100644 --- a/app/Mail/ForumNewReply.php +++ b/app/Mail/ForumNewReply.php @@ -37,7 +37,7 @@ public function build() { return $this ->text('emails.forum.new_reply') - ->subject(trans('mail.forum_new_reply.subject', [ + ->subject(osu_trans('mail.forum_new_reply.subject', [ 'title' => $this->topic->topic_title, ])); } diff --git a/app/Mail/PasswordReset.php b/app/Mail/PasswordReset.php index 14d1133e5a3..44565bf58f0 100644 --- a/app/Mail/PasswordReset.php +++ b/app/Mail/PasswordReset.php @@ -37,6 +37,6 @@ public function build() { return $this ->text('emails.password_reset') - ->subject(trans('mail.password_reset.subject')); + ->subject(osu_trans('mail.password_reset.subject')); } } diff --git a/app/Mail/StorePaymentCompleted.php b/app/Mail/StorePaymentCompleted.php index c2a221ad325..ec6a01d4605 100644 --- a/app/Mail/StorePaymentCompleted.php +++ b/app/Mail/StorePaymentCompleted.php @@ -39,6 +39,6 @@ public function build() return $this->text('emails.store.payment_completed') ->with($this->params) ->from('osustore@ppy.sh', 'osu!store team') - ->subject(trans('mail.store_payment_completed.subject')); + ->subject(osu_trans('mail.store_payment_completed.subject')); } } diff --git a/app/Mail/SupporterGift.php b/app/Mail/SupporterGift.php index 41dff40eadc..b34c04eccab 100644 --- a/app/Mail/SupporterGift.php +++ b/app/Mail/SupporterGift.php @@ -41,6 +41,6 @@ public function build() { return $this->text('emails.store.supporter_gift') ->with($this->params) - ->subject(trans('mail.supporter_gift.subject')); + ->subject(osu_trans('mail.supporter_gift.subject')); } } diff --git a/app/Mail/UserEmailUpdated.php b/app/Mail/UserEmailUpdated.php index 622b5875122..d323209ab99 100644 --- a/app/Mail/UserEmailUpdated.php +++ b/app/Mail/UserEmailUpdated.php @@ -35,6 +35,6 @@ public function build() { return $this ->text('emails.user_email_updated') - ->subject(trans('mail.user_email_updated.subject')); + ->subject(osu_trans('mail.user_email_updated.subject')); } } diff --git a/app/Mail/UserForceReactivation.php b/app/Mail/UserForceReactivation.php index 288f3da3644..dde6d3db7da 100644 --- a/app/Mail/UserForceReactivation.php +++ b/app/Mail/UserForceReactivation.php @@ -26,6 +26,6 @@ public function build() ->with([ 'reason' => $this->reason, 'user' => $this->user, - ])->subject(trans('mail.user_force_reactivation.subject')); + ])->subject(osu_trans('mail.user_force_reactivation.subject')); } } diff --git a/app/Mail/UserNotificationDigest.php b/app/Mail/UserNotificationDigest.php index f05d37ae5d9..df2f1b8e67a 100644 --- a/app/Mail/UserNotificationDigest.php +++ b/app/Mail/UserNotificationDigest.php @@ -50,7 +50,7 @@ private function addToGroups(Notification $notification) } $this->groups[$key] = [ - 'text' => trans($baseKey, $details), + 'text' => osu_trans($baseKey, $details), ]; } @@ -77,6 +77,6 @@ public function build() return $this ->text('emails.user_notification_digest', compact('groups', 'user')) - ->subject(trans('mail.user_notification_digest.subject')); + ->subject(osu_trans('mail.user_notification_digest.subject')); } } diff --git a/app/Mail/UserPasswordUpdated.php b/app/Mail/UserPasswordUpdated.php index bf2cb8a70bc..7fd94de5908 100644 --- a/app/Mail/UserPasswordUpdated.php +++ b/app/Mail/UserPasswordUpdated.php @@ -35,6 +35,6 @@ public function build() { return $this ->text('emails.user_password_updated') - ->subject(trans('mail.user_password_updated.subject')); + ->subject(osu_trans('mail.user_password_updated.subject')); } } diff --git a/app/Mail/UserVerification.php b/app/Mail/UserVerification.php index 9914aad6b32..f78e4699e49 100644 --- a/app/Mail/UserVerification.php +++ b/app/Mail/UserVerification.php @@ -39,6 +39,6 @@ public function build() { return $this ->text('emails.user_verification') - ->subject(trans('mail.user_verification.subject')); + ->subject(osu_trans('mail.user_verification.subject')); } } diff --git a/app/Models/Beatmap.php b/app/Models/Beatmap.php index 370ff2b8685..2105e65c63e 100644 --- a/app/Models/Beatmap.php +++ b/app/Models/Beatmap.php @@ -310,11 +310,11 @@ private function getScores($modelPath, $mode) $mode ?? ($mode = $this->mode); if (!static::isModeValid($mode)) { - throw new ScoreRetrievalException(trans('errors.beatmaps.invalid_mode')); + throw new ScoreRetrievalException(osu_trans('errors.beatmaps.invalid_mode')); } if ($this->mode !== 'osu' && $this->mode !== $mode) { - throw new ScoreRetrievalException(trans('errors.beatmaps.standard_converts_only')); + throw new ScoreRetrievalException(osu_trans('errors.beatmaps.standard_converts_only')); } $mode = studly_case($mode); diff --git a/app/Models/Beatmapset.php b/app/Models/Beatmapset.php index 874bd583219..def4486b620 100644 --- a/app/Models/Beatmapset.php +++ b/app/Models/Beatmapset.php @@ -635,16 +635,16 @@ public function nominate(User $user, array $playmodes = []) $this->resetMemoized(); // ensure we're not using cached/stale event data if (!$this->isPending()) { - throw new InvariantException(trans('beatmaps.nominations.incorrect_state')); + throw new InvariantException(osu_trans('beatmaps.nominations.incorrect_state')); } if ($this->hype < $this->requiredHype()) { - throw new InvariantException(trans('beatmaps.nominations.not_enough_hype')); + throw new InvariantException(osu_trans('beatmaps.nominations.not_enough_hype')); } // check if there are any outstanding issues still if ($this->beatmapDiscussions()->openIssues()->count() > 0) { - throw new InvariantException(trans('beatmaps.nominations.unresolved_issues')); + throw new InvariantException(osu_trans('beatmaps.nominations.unresolved_issues')); } if ($this->isLegacyNominationMode()) { @@ -661,27 +661,27 @@ public function nominate(User $user, array $playmodes = []) } if (!$canNominate) { - throw new InvariantException(trans('beatmapsets.nominate.incorrect_mode', ['mode' => implode(', ', $this->playmodesStr())])); + throw new InvariantException(osu_trans('beatmapsets.nominate.incorrect_mode', ['mode' => implode(', ', $this->playmodesStr())])); } if (!$canFullNominate && $this->requiresFullBNNomination()) { - throw new InvariantException(trans('beatmapsets.nominate.full_bn_required')); + throw new InvariantException(osu_trans('beatmapsets.nominate.full_bn_required')); } } else { $playmodes = array_values(array_intersect($this->playmodesStr(), $playmodes)); if (empty($playmodes)) { - throw new InvariantException(trans('beatmapsets.nominate.hybrid_requires_modes')); + throw new InvariantException(osu_trans('beatmapsets.nominate.hybrid_requires_modes')); } foreach ($playmodes as $mode) { if (!$user->isFullBN($mode) && !$user->isNAT($mode)) { if (!$user->isLimitedBN($mode)) { - throw new InvariantException(trans('beatmapsets.nominate.incorrect_mode', ['mode' => $mode])); + throw new InvariantException(osu_trans('beatmapsets.nominate.incorrect_mode', ['mode' => $mode])); } if ($this->requiresFullBNNomination($mode)) { - throw new InvariantException(trans('beatmapsets.nominate.full_bn_required')); + throw new InvariantException(osu_trans('beatmapsets.nominate.full_bn_required')); } } } @@ -707,7 +707,7 @@ public function nominate(User $user, array $playmodes = []) $modesSatisfied = 0; foreach ($requiredNominations as $mode => $count) { if ($currentNominations[$mode] > $count) { - throw new InvariantException(trans('beatmaps.nominations.too_many')); + throw new InvariantException(osu_trans('beatmaps.nominations.too_many')); } if ($currentNominations[$mode] === $count) { @@ -746,7 +746,7 @@ public function love(User $user) if (!$this->isLoveable()) { return [ 'result' => false, - 'message' => trans('beatmaps.nominations.incorrect_state'), + 'message' => osu_trans('beatmaps.nominations.incorrect_state'), ]; } @@ -771,7 +771,7 @@ public function removeFromLoved(User $user, string $reason) if (!$this->isLoved()) { return [ 'result' => false, - 'message' => trans('beatmaps.nominations.incorrect_state'), + 'message' => osu_trans('beatmaps.nominations.incorrect_state'), ]; } @@ -930,7 +930,7 @@ public function validateHypeBy($user) if (isset($message)) { return [ 'result' => false, - 'message' => trans("model_validation.beatmapset_discussion.hype.{$message}"), + 'message' => osu_trans("model_validation.beatmapset_discussion.hype.{$message}"), ]; } else { return ['result' => true]; @@ -1244,7 +1244,7 @@ public function updateDescription($bbcode, $user) public function toMetaDescription() { - $section = trans('layout.menu.beatmaps._'); + $section = osu_trans('layout.menu.beatmaps._'); return "osu! » {$section} » {$this->artist} - {$this->title}"; } diff --git a/app/Models/Changelog.php b/app/Models/Changelog.php index 1f41268de6d..283eb3fa637 100644 --- a/app/Models/Changelog.php +++ b/app/Models/Changelog.php @@ -101,7 +101,7 @@ public static function placeholder() 'user' => $user, 'user_id' => $user->user_id, 'prefix' => '*', - 'message' => trans('changelog.generic'), + 'message' => osu_trans('changelog.generic'), ]); return $change; diff --git a/app/Models/ChangelogEntry.php b/app/Models/ChangelogEntry.php index 0c7a4ee0eeb..d076de725d6 100644 --- a/app/Models/ChangelogEntry.php +++ b/app/Models/ChangelogEntry.php @@ -160,7 +160,7 @@ public static function isPrivate($data) public static function placeholder() { return new static([ - 'title' => trans('changelog.generic'), + 'title' => osu_trans('changelog.generic'), 'private' => false, 'major' => false, 'created_at' => Carbon::createFromTimestamp(0), diff --git a/app/Models/Chat/Channel.php b/app/Models/Chat/Channel.php index 9d8bcbd5f15..8f247d31370 100644 --- a/app/Models/Chat/Channel.php +++ b/app/Models/Chat/Channel.php @@ -291,17 +291,17 @@ public function receiveMessage(User $sender, string $content, bool $isAction = f ->exec(); if (count($sent) >= $limit) { - throw new API\ExcessiveChatMessagesException(trans('api.error.chat.limit_exceeded')); + throw new API\ExcessiveChatMessagesException(osu_trans('api.error.chat.limit_exceeded')); } $content = str_replace(["\r", "\n"], ' ', trim($content)); if (mb_strlen($content, 'UTF-8') >= config('osu.chat.message_length_limit')) { - throw new API\ChatMessageTooLongException(trans('api.error.chat.too_long')); + throw new API\ChatMessageTooLongException(osu_trans('api.error.chat.too_long')); } if (!present($content)) { - throw new API\ChatMessageEmptyException(trans('api.error.chat.empty')); + throw new API\ChatMessageEmptyException(osu_trans('api.error.chat.empty')); } $chatFilters = app('chat-filters')->all(); diff --git a/app/Models/Contest.php b/app/Models/Contest.php index 0b1a1f8ea28..8723fa6cab1 100644 --- a/app/Models/Contest.php +++ b/app/Models/Contest.php @@ -150,19 +150,19 @@ public function currentPhaseDateRange() switch ($this->state()) { case 'preparing': $date = $this->entry_starts_at === null - ? trans('contest.dates.starts.soon') + ? osu_trans('contest.dates.starts.soon') : i18n_date($this->entry_starts_at); - return trans('contest.dates.starts._', ['date' => $date]); + return osu_trans('contest.dates.starts._', ['date' => $date]); case 'entry': return i18n_date($this->entry_starts_at).' - '.i18n_date($this->entry_ends_at); case 'voting': return i18n_date($this->voting_starts_at).' - '.i18n_date($this->voting_ends_at); default: if ($this->voting_ends_at === null) { - return trans('contest.dates.ended_no_date'); + return osu_trans('contest.dates.ended_no_date'); } else { - return trans('contest.dates.ended', ['date' => i18n_date($this->voting_ends_at)]); + return osu_trans('contest.dates.ended', ['date' => i18n_date($this->voting_ends_at)]); } } } diff --git a/app/Models/Forum/Forum.php b/app/Models/Forum/Forum.php index 207eb2d99b6..99c0f1e7148 100644 --- a/app/Models/Forum/Forum.php +++ b/app/Models/Forum/Forum.php @@ -371,7 +371,7 @@ public function markAsRead(User $user, bool $recursive = false) public function toMetaDescription() { - $stack = [trans('forum.title')]; + $stack = [osu_trans('forum.title')]; foreach ($this->forum_parents as $forumId => $forumData) { $stack[] = $forumData[0]; } diff --git a/app/Models/Store/Order.php b/app/Models/Store/Order.php index 3acb4c3b686..7e732b16512 100644 --- a/app/Models/Store/Order.php +++ b/app/Models/Store/Order.php @@ -413,7 +413,7 @@ public function cancel(?User $user = null) // TODO: Payment processors should set a context variable flagging the user check to be skipped. // This is currently only fine because the Orders controller requires auth. if ($user !== null && $this->user_id === $user->getKey() && !$this->canUserCancel()) { - throw new InvariantException(trans('store.order.cancel_not_allowed')); + throw new InvariantException(osu_trans('store.order.cancel_not_allowed')); } $this->status = 'cancelled'; @@ -465,7 +465,7 @@ public function updateItem(array $itemForm, $addToExisting = false) // TODO: better validation handling. if ($params['product'] === null) { - return trans('model_validation/store/product.not_available'); + return osu_trans('model_validation/store/product.not_available'); } $this->saveOrExplode(); diff --git a/app/Models/SupporterTag.php b/app/Models/SupporterTag.php index c35f2914758..25923dfcbad 100644 --- a/app/Models/SupporterTag.php +++ b/app/Models/SupporterTag.php @@ -91,11 +91,11 @@ public static function getDisplayName(Store\OrderItem $item, bool $html = false) $username = $item->extra_data['username'] ?? ''; return $html - ? blade_safe(trans($transKey, [ + ? blade_safe(osu_trans($transKey, [ 'duration' => e($durationText), 'name' => e($item->product->name), 'username' => link_to_user($item->extra_data['target_id'], $username), - ])) : trans($transKey, [ + ])) : osu_trans($transKey, [ 'duration' => $durationText, 'name' => $item->product->name, 'username' => $username, @@ -110,11 +110,11 @@ public static function getDurationText($length, ?string $locale = null) $texts = []; if ($years > 0) { - $texts[] = trans_choice('common.count.years', $years, [], $locale); + $texts[] = osu_trans_choice('common.count.years', $years, [], $locale); } if ($months > 0) { - $texts[] = trans_choice('common.count.months', $months, [], $locale); + $texts[] = osu_trans_choice('common.count.months', $months, [], $locale); } return implode(', ', $texts); diff --git a/app/Models/Tournament.php b/app/Models/Tournament.php index ea70f168630..da160d3d4a4 100644 --- a/app/Models/Tournament.php +++ b/app/Models/Tournament.php @@ -152,14 +152,14 @@ public function pageLinks() if ($this->info_url !== null) { $links[] = [ 'url' => $this->info_url, - 'title' => trans('tournament.show.info_page'), + 'title' => osu_trans('tournament.show.info_page'), ]; } if ($this->isStoreBannerAvailable()) { $links[] = [ 'url' => route('store.products.show', $this->tournament_banner_product_id), - 'title' => trans('tournament.show.banner'), + 'title' => osu_trans('tournament.show.banner'), ]; } diff --git a/app/Models/User.php b/app/Models/User.php index 37a56e31529..276ba3a8a7a 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -1824,7 +1824,7 @@ public static function attemptLogin($user, $password, $ip = null) if (LoginAttempt::isLocked($ip)) { DatadogLoginAttempt::log('locked_ip'); - return trans('users.login.locked_ip'); + return osu_trans('users.login.locked_ip'); } $authError = null; @@ -1848,7 +1848,7 @@ public static function attemptLogin($user, $password, $ip = null) if ($authError !== null) { LoginAttempt::logAttempt($ip, $user, 'fail', $password); - return trans('users.login.failed'); + return osu_trans('users.login.failed'); } LoginAttempt::logLoggedIn($ip, $user); diff --git a/app/Models/UserNotFound.php b/app/Models/UserNotFound.php index a879d70a6e0..9db6c712255 100644 --- a/app/Models/UserNotFound.php +++ b/app/Models/UserNotFound.php @@ -112,7 +112,7 @@ public static function instance() { static $user; if (!isset($user)) { - $user = new static(['user_id' => -1, 'username' => trans('supporter_tag.user_search.not_found')]); + $user = new static(['user_id' => -1, 'username' => osu_trans('supporter_tag.user_search.not_found')]); } return $user; diff --git a/app/Models/Wiki/Page.php b/app/Models/Wiki/Page.php index 97aa5de4523..ba3f7e28f70 100644 --- a/app/Models/Wiki/Page.php +++ b/app/Models/Wiki/Page.php @@ -425,7 +425,7 @@ public function template() public function title($withSubtitle = false) { if ($this->page === null) { - return trans('wiki.show.missing_title'); + return osu_trans('wiki.show.missing_title'); } $title = presence($this->page['header']['title'] ?? null) ?? $this->defaultTitle; diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index f0ad0d9e649..e7d2d465e43 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -56,12 +56,12 @@ public function boot() }); Passport::tokensCan([ - 'bot' => trans('api.scopes.bot'), - 'forum.write' => trans('api.scopes.forum.write'), - 'chat.write' => trans('api.scopes.chat.write'), - 'friends.read' => trans('api.scopes.friends.read'), - 'identify' => trans('api.scopes.identify'), - 'public' => trans('api.scopes.public'), + 'bot' => osu_trans('api.scopes.bot'), + 'forum.write' => osu_trans('api.scopes.forum.write'), + 'chat.write' => osu_trans('api.scopes.chat.write'), + 'friends.read' => osu_trans('api.scopes.friends.read'), + 'identify' => osu_trans('api.scopes.identify'), + 'public' => osu_trans('api.scopes.public'), ]); } } diff --git a/app/Transformers/CommentableMetaTransformer.php b/app/Transformers/CommentableMetaTransformer.php index 6e1bb1edbc5..62cb20cbdf2 100644 --- a/app/Transformers/CommentableMetaTransformer.php +++ b/app/Transformers/CommentableMetaTransformer.php @@ -28,7 +28,7 @@ public function transform(?Commentable $commentable) ]; } else { return [ - 'title' => trans('comments.commentable_name._deleted'), + 'title' => osu_trans('comments.commentable_name._deleted'), ]; } } diff --git a/app/Transformers/GenreTransformer.php b/app/Transformers/GenreTransformer.php index a3251355aff..8f3ccbb5b89 100644 --- a/app/Transformers/GenreTransformer.php +++ b/app/Transformers/GenreTransformer.php @@ -13,7 +13,7 @@ public function transform(Genre $genre) { return [ 'id' => $genre->genre_id === 0 ? null : $genre->genre_id, - 'name' => trans('beatmaps.genre.'.str_replace(' ', '-', strtolower($genre->name))), + 'name' => osu_trans('beatmaps.genre.'.str_replace(' ', '-', strtolower($genre->name))), ]; } } diff --git a/app/Transformers/LanguageTransformer.php b/app/Transformers/LanguageTransformer.php index 586aa8a288e..d4d060d2ab7 100644 --- a/app/Transformers/LanguageTransformer.php +++ b/app/Transformers/LanguageTransformer.php @@ -13,7 +13,7 @@ public function transform(Language $language) { return [ 'id' => $language->language_id === 0 ? null : $language->language_id, - 'name' => trans('beatmaps.language.'.str_replace(' ', '-', strtolower($language->name))), + 'name' => osu_trans('beatmaps.language.'.str_replace(' ', '-', strtolower($language->name))), ]; } } diff --git a/app/framework_helper_overrides.php b/app/framework_helper_overrides.php index e5d5a96dcc3..2b518e99c7d 100644 --- a/app/framework_helper_overrides.php +++ b/app/framework_helper_overrides.php @@ -12,35 +12,3 @@ function e($value) return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', true); } - -function trans($key = null, $replace = [], $locale = null) -{ - $translator = app('translator'); - - if (is_null($key)) { - return $translator; - } - - if (!trans_exists($key, $locale)) { - $locale = config('app.fallback_locale'); - } - - return $translator->get($key, $replace, $locale, false); -} - -function trans_choice($key, $number, array $replace = [], $locale = null) -{ - if (!trans_exists($key, $locale)) { - $locale = config('app.fallback_locale'); - } - - if (is_array($number) || $number instanceof Countable) { - $number = count($number); - } - - if (!isset($replace['count_delimited'])) { - $replace['count_delimited'] = i18n_number_format($number, null, null, null, $locale); - } - - return app('translator')->choice($key, $number, $replace, $locale); -} diff --git a/app/helpers.php b/app/helpers.php index 876b7da7e1e..45b6abadab9 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -427,6 +427,38 @@ function oauth_token(): ?App\Models\OAuth\Token return request()->attributes->get(App\Http\Middleware\AuthApi::REQUEST_OAUTH_TOKEN_KEY); } +function osu_trans($key = null, $replace = [], $locale = null) +{ + $translator = app('translator'); + + if (is_null($key)) { + return $translator; + } + + if (!trans_exists($key, $locale)) { + $locale = config('app.fallback_locale'); + } + + return $translator->get($key, $replace, $locale, false); +} + +function osu_trans_choice($key, $number, array $replace = [], $locale = null) +{ + if (!trans_exists($key, $locale)) { + $locale = config('app.fallback_locale'); + } + + if (is_array($number) || $number instanceof Countable) { + $number = count($number); + } + + if (!isset($replace['count_delimited'])) { + $replace['count_delimited'] = i18n_number_format($number, null, null, null, $locale); + } + + return app('translator')->choice($key, $number, $replace, $locale); +} + function osu_url($key) { $url = config("osu.urls.{$key}"); @@ -473,12 +505,12 @@ function product_quantity_options($product, $selected = null) $opts = []; for ($i = 1; $i <= $max; $i++) { - $opts[$i] = trans_choice('common.count.item', $i); + $opts[$i] = osu_trans_choice('common.count.item', $i); } // include selected value separately if it's out of range. if ($selected > $max) { - $opts[$selected] = trans_choice('common.count.item', $selected); + $opts[$selected] = osu_trans_choice('common.count.item', $selected); } return $opts; @@ -525,9 +557,9 @@ function request_country($request = null) function require_login($text_key, $link_text_key) { - $title = trans('users.anonymous.login_link'); - $link = Html::link('#', trans($link_text_key), ['class' => 'js-user-link', 'title' => $title]); - $text = trans($text_key, ['link' => $link]); + $title = osu_trans('users.anonymous.login_link'); + $link = Html::link('#', osu_trans($link_text_key), ['class' => 'js-user-link', 'title' => $title]); + $text = osu_trans($text_key, ['link' => $link]); return $text; } @@ -567,9 +599,9 @@ function to_sentence($array, $key = 'common.array_and') case 1: return (string) $array[0]; case 2: - return implode(trans("{$key}.two_words_connector"), $array); + return implode(osu_trans("{$key}.two_words_connector"), $array); default: - return implode(trans("{$key}.words_connector"), array_slice($array, 0, -1)).trans("{$key}.last_word_connector").array_last($array); + return implode(osu_trans("{$key}.words_connector"), array_slice($array, 0, -1)).osu_trans("{$key}.last_word_connector").array_last($array); } } @@ -710,7 +742,7 @@ function page_title() foreach ($keys as $key) { if (trans_exists($key, $checkLocale)) { - return trans($key); + return osu_trans($key); } } @@ -1032,10 +1064,10 @@ function display_regdate($user) $formattedDate = i18n_date($user->user_regdate, null, 'year_month'); if ($user->user_regdate < Carbon\Carbon::createFromDate(2008, 1, 1)) { - return '
'.trans('users.show.first_members').'
'; + return '
'.osu_trans('users.show.first_members').'
'; } - return trans('users.show.joined_at', [ + return osu_trans('users.show.joined_at', [ 'date' => "{$formattedDate}", ]); } @@ -1049,7 +1081,7 @@ function i18n_date($datetime, $format = IntlDateFormatter::LONG, $pattern = null ); if ($pattern !== null) { - $formatter->setPattern(trans("common.datetime.{$pattern}.php")); + $formatter->setPattern(osu_trans("common.datetime.{$pattern}.php")); } return $formatter->format($datetime); @@ -1619,9 +1651,9 @@ function search_error_message(?Exception $e): ?string $basename = snake_case(get_class_basename(get_class($e))); $key = "errors.search.${basename}"; - $text = trans($key); + $text = osu_trans($key); - return $text === $key ? trans('errors.search.default') : $text; + return $text === $key ? osu_trans('errors.search.default') : $text; } /** diff --git a/bin/phpunit.sh b/bin/phpunit.sh index d2a1c389030..93de129f5b1 100755 --- a/bin/phpunit.sh +++ b/bin/phpunit.sh @@ -4,4 +4,4 @@ cd "$(dirname "$0")/.." export APP_URL=http://localhost -exec vendor/bin/phpunit --prepend=app/framework_helper_overrides.php "$@" +exec vendor/bin/phpunit "$@" diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php deleted file mode 100644 index 60baafe2797..00000000000 --- a/bootstrap/autoload.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ +use Illuminate\Contracts\Http\Kernel; +use Illuminate\Http\Request; + +define('LARAVEL_START', microtime(true)); /* |-------------------------------------------------------------------------- -| Register The Auto Loader +| Check If The Application Is Under Maintenance |-------------------------------------------------------------------------- | -| Composer provides a convenient, automatically generated class loader for -| our application. We just need to utilize it! We'll simply require it -| into the script here so that we don't have to worry about manual -| loading any of our classes later on. It feels nice to relax. +| If the application is in maintenance / demo mode via the "down" command +| we will load this file so that any pre-rendered content can be shown +| instead of starting the framework, which could cause an exception. | */ -require __DIR__.'/../bootstrap/autoload.php'; +if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) { + require __DIR__.'/../storage/framework/maintenance.php'; +} /* |-------------------------------------------------------------------------- -| Turn On The Lights +| Register The Auto Loader |-------------------------------------------------------------------------- | -| We need to illuminate PHP development, so let us turn on the lights. -| This bootstraps the framework and gets it ready for use, then it -| will load up this application so that we can run it and send -| the responses back to the browser and delight our users. +| Composer provides a convenient, automatically generated class loader for +| this application. We just need to utilize it! We'll simply require it +| into the script here so we don't need to manually load our classes. | */ -$app = require_once __DIR__.'/../bootstrap/app.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | -| Once we have the application, we can simply call the run method, -| which will execute the request and send the response back to -| the client's browser allowing them to enjoy the creative -| and wonderful application we have prepared for them. +| Once we have the application, we can handle the incoming request using +| the application's HTTP kernel. Then, we will send the response back +| to this client's browser, allowing them to enjoy our application. | */ -$kernel = $app->make('Illuminate\Contracts\Http\Kernel'); +$app = require_once __DIR__.'/../bootstrap/app.php'; -$response = $kernel->handle( - $request = Illuminate\Http\Request::capture() -); +$kernel = $app->make(Kernel::class); -$response->send(); +$response = tap($kernel->handle( + $request = Request::capture() +))->send(); $kernel->terminate($request, $response); diff --git a/resources/views/accounts/_edit_email.blade.php b/resources/views/accounts/_edit_email.blade.php index 457fe5b4926..e4b7b5c7575 100644 --- a/resources/views/accounts/_edit_email.blade.php +++ b/resources/views/accounts/_edit_email.blade.php @@ -11,7 +11,7 @@ ]) !!}

- {{ trans('accounts.edit.email.title') }} + {{ osu_trans('accounts.edit.email.title') }}

@@ -26,7 +26,7 @@ class="account-edit-entry__input" >
- {{ trans('accounts.edit.password.current') }} + {{ osu_trans('accounts.edit.password.current') }}
@@ -42,7 +42,7 @@ class="account-edit-entry__input js-form-confirmation" >
- {{ trans('accounts.edit.email.new') }} + {{ osu_trans('accounts.edit.email.new') }}
@@ -56,7 +56,7 @@ class="account-edit-entry__input js-form-confirmation" >
- {{ trans('accounts.edit.email.new_confirmation') }} + {{ osu_trans('accounts.edit.email.new_confirmation') }}
@@ -65,10 +65,10 @@ class="account-edit-entry__input js-form-confirmation"
- + >{{osu_trans('accounts.security.end_session')}}
@endforeach diff --git a/resources/views/accounts/_edit_signature.blade.php b/resources/views/accounts/_edit_signature.blade.php index b1592f08afa..e5a61d72840 100644 --- a/resources/views/accounts/_edit_signature.blade.php +++ b/resources/views/accounts/_edit_signature.blade.php @@ -10,7 +10,7 @@ ]) !!}

- {{ trans('accounts.edit.signature.title') }} + {{ osu_trans('accounts.edit.signature.title') }}

@@ -51,14 +51,14 @@ class="account-edit-entry__input js-post-preview--auto js-bbcode-body" @foreach (array_merge(['raw', 'fullsize'], $beatmapset->coverSizes()) as $size)

{{$size}}

diff --git a/resources/views/admin/beatmapsets/show.blade.php b/resources/views/admin/beatmapsets/show.blade.php index 9468fae52d1..dd8f9304014 100644 --- a/resources/views/admin/beatmapsets/show.blade.php +++ b/resources/views/admin/beatmapsets/show.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('layout.header.admin.beatmapset')]) +@extends('master', ['titlePrepend' => osu_trans('layout.header.admin.beatmapset')]) @section('content') @include('admin/_header') @@ -10,11 +10,11 @@

{{ $beatmapset->title }} - {{ $beatmapset->artist }}

@endsection diff --git a/resources/views/admin/contests/index.blade.php b/resources/views/admin/contests/index.blade.php index 92fa96927e2..e27624da188 100644 --- a/resources/views/admin/contests/index.blade.php +++ b/resources/views/admin/contests/index.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('layout.header.admin.contests')]) +@extends('master', ['titlePrepend' => osu_trans('layout.header.admin.contests')]) @section('content') diff --git a/resources/views/admin/contests/show.blade.php b/resources/views/admin/contests/show.blade.php index ae8fc5c6e87..b571660709d 100644 --- a/resources/views/admin/contests/show.blade.php +++ b/resources/views/admin/contests/show.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('layout.header.admin.contest').' / '.$contest->name]) +@extends('master', ['titlePrepend' => osu_trans('layout.header.admin.contest').' / '.$contest->name]) @section('content') @include('objects.css-override', ['mapping' => [ diff --git a/resources/views/admin/forum/forum_covers/index.blade.php b/resources/views/admin/forum/forum_covers/index.blade.php index 58b96023aa4..63449e9a37c 100644 --- a/resources/views/admin/forum/forum_covers/index.blade.php +++ b/resources/views/admin/forum/forum_covers/index.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('admin.forum.forum-covers.index.title')]) +@extends('master', ['titlePrepend' => osu_trans('admin.forum.forum-covers.index.title')]) @section('content') @include('admin/_header') @@ -13,7 +13,7 @@

{!! link_to( route('forum.forums.show', $forum->forum_id), - trans('admin.forum.forum-covers.index.forum-name', ['id' => $forum->forum_id, 'name' => $forum->forum_name]) + osu_trans('admin.forum.forum-covers.index.forum-name', ['id' => $forum->forum_id, 'name' => $forum->forum_name]) ) !!}

@@ -22,7 +22,7 @@ 'default-topic' => ['cover' => $forum->cover->defaultTopicCover ?? null, 'key' => 'default_topic_cover'] ] as $type => $cover)
-

{{ trans("admin.forum.forum-covers.index.type-title.{$type}") }}

+

{{ osu_trans("admin.forum.forum-covers.index.type-title.{$type}") }}

@if ($cover['cover'] !== null && $cover['cover']->fileUrl() !== null)
- {{ trans('admin.forum.forum-covers.index.delete') }} + {{ osu_trans('admin.forum.forum-covers.index.delete') }} - + {!! Form::close() !!} @else - {{ trans('admin.forum.forum-covers.index.no-cover') }} + {{ osu_trans('admin.forum.forum-covers.index.no-cover') }} {!! Form::open(['url' => route('admin.forum.forum-covers.store'), 'method' => 'POST', 'files' => true]) !!} - + {!! Form::close() !!} @endif
diff --git a/resources/views/admin/logs/index.blade.php b/resources/views/admin/logs/index.blade.php index d1c7b8a533b..f018384bddd 100644 --- a/resources/views/admin/logs/index.blade.php +++ b/resources/views/admin/logs/index.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('admin.logs.index.title')]) +@extends('master', ['titlePrepend' => osu_trans('admin.logs.index.title')]) @section('content') @include('admin/_header') diff --git a/resources/views/admin/pages/root.blade.php b/resources/views/admin/pages/root.blade.php index 71040664e80..9a09f403acd 100644 --- a/resources/views/admin/pages/root.blade.php +++ b/resources/views/admin/pages/root.blade.php @@ -7,11 +7,11 @@ @section('content') @include('admin._header')
-

{{ trans('admin.pages.root.sections.general') }}

+

{{ osu_trans('admin.pages.root.sections.general') }}

-

{{ trans('admin.pages.root.sections.store') }}

+

{{ osu_trans('admin.pages.root.sections.store') }}

-

{{ trans('admin.pages.root.sections.forum') }}

+

{{ osu_trans('admin.pages.root.sections.forum') }}

diff --git a/resources/views/admin/store/orders/show.blade.php b/resources/views/admin/store/orders/show.blade.php index 50517d2c5e5..4834b37e4e4 100644 --- a/resources/views/admin/store/orders/show.blade.php +++ b/resources/views/admin/store/orders/show.blade.php @@ -2,7 +2,7 @@ Copyright (c) ppy Pty Ltd . Licensed under the GNU Affero General Public License v3.0. See the LICENCE file in the repository root for full licence text. --}} -@extends('master', ['titlePrepend' => trans('layout.header.admin.store_orders')]) +@extends('master', ['titlePrepend' => osu_trans('layout.header.admin.store_orders')]) @section('content') @@ -47,13 +47,13 @@
-
{{ trans("store.admin.warehouse") }}
+
{{ osu_trans("store.admin.warehouse") }}
- - + + @foreach ($ordersItemsQuantities as $ordersItemsQuantity) diff --git a/resources/views/artists/index.blade.php b/resources/views/artists/index.blade.php index 0c54fc0ff35..28b12f9fa38 100644 --- a/resources/views/artists/index.blade.php +++ b/resources/views/artists/index.blade.php @@ -3,13 +3,13 @@ See the LICENCE file in the repository root for full licence text. --}} @extends('master', [ - 'pageDescription' => trans('artist.page_description'), + 'pageDescription' => osu_trans('artist.page_description'), ]) @section('content') @include('layout._page_header_v4', ['params' => [ 'links' => [[ - 'title' => trans('layout.header.artists.index'), + 'title' => osu_trans('layout.header.artists.index'), 'url' => route('artists.index'), ]], 'linksBreadcrumb' => true, @@ -18,7 +18,7 @@
-
{!! trans('artist.index.description') !!}
+
{!! osu_trans('artist.index.description') !!}
@foreach ($artists as $artist)
@@ -29,12 +29,12 @@ @endif @if($artist->hasNewTracks()) - {{trans('common.badges.new')}} + {{osu_trans('common.badges.new')}} @endif
{{$artist->name}} -
{{trans_choice('artist.songs.count', $artist->tracks_count)}}
+
{{osu_trans_choice('artist.songs.count', $artist->tracks_count)}}
@endforeach
diff --git a/resources/views/artists/show.blade.php b/resources/views/artists/show.blade.php index 0a502c67209..5d7e8a26a24 100644 --- a/resources/views/artists/show.blade.php +++ b/resources/views/artists/show.blade.php @@ -5,7 +5,7 @@ @php $headerLinks = [ [ - 'title' => trans('layout.header.artists.index'), + 'title' => osu_trans('layout.header.artists.index'), 'url' => route('artists.index'), ], [ @@ -41,7 +41,7 @@
@if (!$artist->visible) -
{{ trans('artist.admin.hidden') }}
+
{{ osu_trans('artist.admin.hidden') }}
@endif

{{ $artist->name }}

@@ -60,7 +60,7 @@ @if ($album['is_new']) - {{trans('common.badges.new')}} + {{osu_trans('common.badges.new')}} @endif @@ -77,7 +77,7 @@
- {{trans('artist.songs._')}} + {{osu_trans('artist.songs._')}}
{{ trans("store.product.name") }}{{ trans("store.order.item.quantity") }}{{ osu_trans("store.product.name") }}{{ osu_trans("store.order.item.quantity") }}