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

isValid() public static method

Returns true if the supplied locale is valid.
public static isValid ( $locale ) : boolean
return boolean
    public static function isValid($locale)
    {
        $languages = array_keys(Locale::listEnabled());
        return in_array($locale, $languages);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Changes the locale in the application and optionally stores it in the session.
  * @param   string  $locale   Locale to use
  * @param   boolean $remember Set to false to not store in the session.
  * @return  boolean Returns true if the locale exists and is set.
  */
 public function setLocale($locale, $remember = true)
 {
     if (!Locale::isValid($locale)) {
         return false;
     }
     App::setLocale($locale);
     $this->activeLocale = $locale;
     if ($remember) {
         $this->setSessionLocale($locale);
     }
     return true;
 }
All Usage Examples Of RainLab\Translate\Models\Locale::isValid