Skip to content

Commit

Permalink
Remove framework helper override
Browse files Browse the repository at this point in the history
For better interoperability with octane.
Rename trans(_choice) to osu_trans(_choice).
  • Loading branch information
nanaya committed Jun 28, 2021
1 parent 06bea20 commit d0d8ad1
Show file tree
Hide file tree
Showing 252 changed files with 1,012 additions and 1,034 deletions.
4 changes: 2 additions & 2 deletions app/Exceptions/OrderNotModifiableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/UserVerificationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ArtistsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BeatmapDiscussionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/BeatmapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Beatmapsets/FavouritesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BeatmapsetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/BlocksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FallbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FriendsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/OAuth/ClientsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Passport/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ("#").
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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(),
Expand 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 = [
Expand All @@ -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}")];
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Payments/PaypalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -126,6 +126,6 @@ private function userErrorMessage($e)
$key = 'paypal/errors.unknown';
}

return trans($key);
return osu_trans($key);
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/SessionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Store/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckUserBanStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckUserRestricted.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/Libraries/AuthorizationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function message()
return;
}

return trans('authorization.'.$this->rawMessage());
return osu_trans('authorization.'.$this->rawMessage());
}

public function ensureCan()
Expand Down
Loading

0 comments on commit d0d8ad1

Please sign in to comment.