Xinax\LaravelGettext\LaravelGettext::getSupportedLocales PHP Method

getSupportedLocales() public method

Returns supported locales
public getSupportedLocales ( ) : array
return array
    public function getSupportedLocales()
    {
        return $this->translator->supportedLocales();
    }

Usage Example

Ejemplo n.º 1
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;
 }