The
trans
function translates the given translation key using your localization files:<?php echo trans('messages.welcome');
<?php $attribute = $translator->get("validation.attributes.{$name}");
if ($attribute === "validation.attributes.{$name}") $attribute = $name;
$message = trans('validation.uploaded', ['attribute' => $attribute]);
if ($message === 'validation.uploaded') $message = "The {$name} failed to upload.";
throw ValidationException::withMessages([$name => $message]);
<?php if ($this->as) {
if (is_array($this->as)) {
$as = $this->translate
? array_map(fn ($i) => trans($i), $this->as)
: $this->as;
$target->addValidationAttributesFromOutside($as);
<?php $target->addValidationAttributesFromOutside($as);
} else {
$target->addValidationAttributesFromOutside([$name => $this->translate ? trans($this->as) : $this->as]);
}
}
<?php if ($this->message) {
if (is_array($this->message)) {
$messages = $this->translate
? array_map(fn ($i) => trans($i), $this->message)
: $this->message;
$target->addMessagesFromOutside($messages);
<?php $rule = (string) str($rule)->before(':');
$target->addMessagesFromOutside([$name.'.'.$rule => $this->translate ? trans($this->message) : $this->message]);
}
}
<?php return $key;
}
return trans($key, $replace, $locale);
}
}
<?php protected function sendResetResponse(Request $request, $response)
{
if ($request->wantsJson()) {
return new JsonResponse(['message' => trans($response)], 200);
}
return redirect($this->redirectPath())
<?php }
return redirect($this->redirectPath())
->with('status', trans($response));
}
<?php {
if ($request->wantsJson()) {
throw ValidationException::withMessages([
'email' => [trans($response)],
]);
}
<?php return redirect()->back()
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
<?php : back();
return $request->wantsJson()
? new JsonResponse(['message' => trans($response)], 200)
: $redirect->with('status', trans($response));
}
<?php return $request->wantsJson()
? new JsonResponse(['message' => trans($response)], 200)
: $redirect->with('status', trans($response));
}
<?php if ($request->wantsJson()) {
throw ValidationException::withMessages([
'email' => [trans($response)],
]);
}
<?php return $redirect
->withInput($request->only('email'))
->withErrors(['email' => trans($response)], 'user.forgot_password');
}
<?php protected function sendFailedLoginResponse(Request $request)
{
throw ValidationException::withMessages([
$this->username() => [trans('auth.failed')],
]);
}