當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Translator::getLocale方法代碼示例

本文整理匯總了PHP中Illuminate\Translation\Translator::getLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translator::getLocale方法的具體用法?PHP Translator::getLocale怎麽用?PHP Translator::getLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Translation\Translator的用法示例。


在下文中一共展示了Translator::getLocale方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: translate

 /**
  * 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;
 }
開發者ID:JimLfe,項目名稱:Localization,代碼行數:23,代碼來源:RouteTranslator.php

示例2: getBody

 /**
  *    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;
 }
開發者ID:SerdarSanri,項目名稱:mailman,代碼行數:23,代碼來源:Message.php

示例3: getLocale

 /**
  * Get the default locale being used.
  *
  * @return string 
  * @static 
  */
 public static function getLocale()
 {
     return \Illuminate\Translation\Translator::getLocale();
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:10,代碼來源:_ide_helper.php

示例4: getLocale

 /**
  * Get the selected locale.
  *
  * @return string
  */
 public function getLocale()
 {
     return $this->locale === 'auto' ? $this->translator->getLocale() : $this->locale;
 }
開發者ID:vjandrea,項目名稱:LogViewer,代碼行數:9,代碼來源:LogLevels.php

示例5: getLocale

 /**
  * {@inheritdoc}
  *
  * @return string The locale
  *
  * @api
  */
 public function getLocale()
 {
     return $this->lang->getLocale();
 }
開發者ID:realholgi,項目名稱:cmsable,代碼行數:11,代碼來源:Translator.php

示例6: getDefaultLocale

 /**
  * Get the default locale being used.
  *
  * @return string
  */
 public function getDefaultLocale()
 {
     return $this->translator->getLocale();
 }
開發者ID:ARCANEDEV,項目名稱:LaravelLang,代碼行數:9,代碼來源:TransChecker.php

示例7: 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();
 }
開發者ID:vsch,項目名稱:laravel-translation-manager,代碼行數:15,代碼來源:Translator.php


注:本文中的Illuminate\Translation\Translator::getLocale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。