core/cgi/Locale.class.php
public function set(string $locale, string $collate): bool {
    $auth = false;
    try {
      if (!empty($locale)) {
        $_locale = preg_replace("/^(\w{2})-(\w{2})$/", "$1_$2", $locale);
        locale_set_default($_locale);
        if (!empty($collate)) {
          $_locale .= "." . strtoupper($collate);
        }
        setlocale(LC_ALL, $_locale);
        $auth = true;
      }
    } catch (Exception $ex) {
      $auth = false;
      throw $ex;
    }
    return $auth;
  }
public function set(string $locale, string $collate): bool {
    $auth = false;
    try {
      if (!empty($locale)) {
        $_locale = preg_replace("/^(\w{2})-(\w{2})$/", "$1_$2", $locale);
        locale_set_default($_locale);
        if (!empty($collate)) {
          $_locale .= "." . strtoupper($collate);
        }
        setlocale(LC_ALL, $_locale);
        $auth = true;
      }
    } catch (Exception $ex) {
      $auth = false;
      throw $ex;
    }
    return $auth;
  }
public function set ( string $ locale , string $ collate ) : bool { $ auth = false ; try { if ( ! empty ( $ locale ) ) { $ _locale = preg_replace ( "/^(\w{2})-(\w{2})$/" , "$1_$2" , $ locale ) ; locale_set_default ( $ _locale ) ; if ( ! empty ( $ collate ) ) { $ _locale .= "." . strtoupper ( $ collate ) ; } setlocale ( LC_ALL , $ _locale ) ; $ auth = true ; } } catch ( Exception $ ex ) { $ auth = false ; throw $ ex ; } return $ auth ; }
- Set locale and collate
@param string $locale Codename of locale (Ex: en-US)
@param string $collate Codename of collate (Ex: utf-8)
@return bool Return true case locale set, or false case fail
- Set locale and collate