LaravelLocalization::setLocale PHP Method

setLocale() public static method

Set and return current locale
public static setLocale ( string $locale = null ) : string
$locale string Locale to set the App to (optional)
return string Returns locale (if route has any) or null (if route does not have a locale)
        public static function setLocale($locale = null)
        {
            return \Mcamara\LaravelLocalization\LaravelLocalization::setLocale($locale);
        }

Usage Example

Beispiel #1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $params = $this->params;
     $localization = \Mcamara\LaravelLocalization\LaravelLocalization::class;
     if (class_exists($localization)) {
         \LaravelLocalization::setLocale($this->locale);
     }
     app()->setLocale($this->locale);
     if ($this->type == 'Normal') {
         // Text send
         Mail::raw($params['html'], function ($message) use($params) {
             if ($params['attach']) {
                 $message->attach($params['attach']);
             }
             $message->to($params['to'])->from(env('MAIL_USERNAME'), $params['fromName'])->subject($params['subject']);
         });
     } elseif ($this->type == 'Template') {
         // Template send
         Mail::send($params['templateInvokeName'], $params['xsmtpapi'], function ($message) use($params) {
             if ($params['attach']) {
                 $message->attach($params['attach']);
             }
             $message->to($params['to'])->from(env('MAIL_USERNAME'), $params['fromName'])->subject($params['subject']);
         });
     }
     $fileDir = $this->getSwiftmailLogDir();
     $this->logInfo('[' . Carbon::now($this->local)->format('Y-m-d H:i:s') . ']' . json_encode($params, JSON_UNESCAPED_UNICODE) . chr(10), $fileDir);
 }
All Usage Examples Of LaravelLocalization::setLocale