예제 #1
0
 /**
  * Get the translation for a given key.
  *
  * @param  string  $key
  * @param  string  $locale
  *
  * @return string
  *
  * @throws InvalidTranslationException
  */
 private function translate($key, $locale = null)
 {
     if (is_null($locale)) {
         $locale = $this->translator->getLocale();
     }
     $translation = $this->translator->trans($key, [], '', $locale);
     // @codeCoverageIgnoreStart
     if (!is_string($translation)) {
         throw new InvalidTranslationException("The translation key [{$key}] for locale [{$locale}] should return a string value.");
     }
     // @codeCoverageIgnoreEnd
     return (string) $translation;
 }
예제 #2
0
 /**
  *    Return the HTML representation of the email to be sent.
  *
  *    @return string
  */
 public function getBody()
 {
     // Set the email's locale:
     $appLocale = $this->translator->getLocale();
     if ($this->locale && $this->locale != $appLocale) {
         $this->translator->setLocale($this->locale);
     }
     // Generate HTML:
     $html = $this->viewFactory->make($this->view, $this->data)->render();
     $css = $this->filesystem->get(base_path($this->cssFile));
     $inliner = new CssToInlineStyles($html, $css);
     $body = $inliner->convert();
     // Return App locale to former value:
     if ($this->locale && $this->locale != $appLocale) {
         $this->translator->setLocale($appLocale);
     }
     return $body;
 }
예제 #3
0
 /**
  * Get the default locale being used.
  *
  * @return string 
  * @static 
  */
 public static function getLocale()
 {
     return \Illuminate\Translation\Translator::getLocale();
 }
예제 #4
0
 /**
  * Get the selected locale.
  *
  * @return string
  */
 public function getLocale()
 {
     return $this->locale === 'auto' ? $this->translator->getLocale() : $this->locale;
 }
예제 #5
0
 /**
  * {@inheritdoc}
  *
  * @return string The locale
  *
  * @api
  */
 public function getLocale()
 {
     return $this->lang->getLocale();
 }
예제 #6
0
 /**
  * Get the default locale being used.
  *
  * @return string
  */
 public function getDefaultLocale()
 {
     return $this->translator->getLocale();
 }
 /**
  * Get the default locale being used.
  *
  * @return string
  */
 public function getLocale()
 {
     if ($this->useCookies) {
         $locale = \Cookie::get($this->cookiePrefix . 'lang_locale', parent::getLocale());
         if ($locale != parent::getLocale()) {
             parent::setLocale($locale);
         }
     }
     return parent::getLocale();
 }