getLocale() public method

Gets the Current locale.
public getLocale ( ) : string
return string
コード例 #1
0
 /**
  * Renders the language selector
  * @return string
  */
 public function render($twBoot = false)
 {
     /** @var array $locales */
     $locales = Config::get('laravel-gettext.supported-locales');
     /** @var string $currentLocale */
     $currentLocale = $this->gettext->getLocale();
     switch ($twBoot) {
         case true:
             return $this->renderBootstrap($locales, $currentLocale);
             break;
         default:
             return $this->render($locales, $currentLocale);
     }
 }
コード例 #2
0
 /**
  * Renders the language selector
  * @return String
  */
 public function render()
 {
     $html = '<ul class="language-selector">';
     foreach (Config::get('laravel-gettext.supported-locales') as $locale) {
         if (count($this->labels) && array_key_exists($locale, $this->labels)) {
             $localeLabel = $this->labels[$locale];
         } else {
             $localeLabel = $locale;
         }
         if ($locale == $this->gettext->getLocale()) {
             $html .= '<li><strong class="active ' . $locale . '">' . $localeLabel . '</strong></li>';
         } else {
             $html .= '<li><a href="/lang/' . $locale . '" class="' . $locale . '">' . $localeLabel . '</a></li>';
         }
     }
     $html .= '</ul>';
     return $html;
 }
コード例 #3
0
 /**
  * Renders the language selector
  * @return string
  */
 public function render()
 {
     /** @var string $currentLocale */
     $currentLocale = $this->gettext->getLocale();
     $html = '<ul class="language-selector">';
     foreach ($this->gettext->getSupportedLocales() as $locale) {
         $localeLabel = $locale;
         // Check if label exists
         if (array_key_exists($locale, $this->labels)) {
             $localeLabel = $this->labels[$locale];
         }
         $link = '<a href="/lang/' . $locale . '" class="' . $locale . '">' . $localeLabel . '</a>';
         if ($locale == $currentLocale) {
             $link = '<strong class="active ' . $locale . '">' . $localeLabel . '</strong>';
         }
         $html .= '<li>' . $link . '</li>';
     }
     $html .= '</ul>';
     return $html;
 }
コード例 #4
0
 /**
  * Test getLocale() method.
  */
 public function testGetLocale()
 {
     $this->assertEquals('en_US', $this->laravelGettext->getLocale());
 }