RainLab\Translate\Models\Locale::listEnabled PHP Method

listEnabled() public static method

Lists the enabled locales, used on the front-end.
public static listEnabled ( ) : array
return array
    public static function listEnabled()
    {
        if (self::$cacheListEnabled) {
            return self::$cacheListEnabled;
        }
        $isEnabled = Cache::remember('rainlab.translate.locales', 1440, function () {
            return self::isEnabled()->lists('name', 'code');
        });
        return self::$cacheListEnabled = $isEnabled;
    }

Usage Example

 public function onRun()
 {
     if ($redirect = $this->redirectForceUrl()) {
         return $redirect;
     }
     $this->page['locales'] = $this->locales = LocaleModel::listEnabled();
     $this->page['activeLocale'] = $this->activeLocale = $this->translator->getLocale();
     $this->page['activeLocaleName'] = $this->activeLocaleName = array_get($this->locales, $this->activeLocale);
 }
All Usage Examples Of RainLab\Translate\Models\Locale::listEnabled