Horde_Nls::getLocaleInfo PHP Method

getLocaleInfo() public static method

Get the locale info returned by localeconv(), but cache it, to avoid repeated calls.
public static getLocaleInfo ( ) : array
return array The results of localeconv().
    public static function getLocaleInfo()
    {
        if (!isset(self::$_cache['lc_info'])) {
            self::$_cache['lc_info'] = localeconv();
        }
        return self::$_cache['lc_info'];
    }

Usage Example

Example #1
0
 /**
  */
 protected function _getValidationPattern()
 {
     static $pattern = '';
     if (!empty($pattern)) {
         return $pattern;
     }
     /* Get current locale information. */
     $linfo = Horde_Nls::getLocaleInfo();
     /* Build the pattern. */
     $pattern = '(-)?';
     /* Only check thousands separators if locale has any. */
     if (!empty($linfo['mon_thousands_sep'])) {
         /* Regex to check for correct thousands separators (if any). */
         $pattern .= '((\\d+)|((\\d{0,3}?)([' . $linfo['mon_thousands_sep'] . ']\\d{3})*?))';
     } else {
         /* No locale thousands separator, check for only digits. */
         $pattern .= '(\\d+)';
     }
     /* If no decimal point specified default to dot. */
     if (empty($linfo['mon_decimal_point'])) {
         $linfo['mon_decimal_point'] = '.';
     }
     /* Regex to check for correct decimals (if any). */
     if (empty($this->_fraction)) {
         $fraction = '*';
     } else {
         $fraction = '{0,' . $this->_fraction . '}';
     }
     $pattern .= '([' . $linfo['mon_decimal_point'] . '](\\d' . $fraction . '))?';
     /* Put together the whole regex pattern. */
     $pattern = '/^' . $pattern . '$/';
     return $pattern;
 }
All Usage Examples Of Horde_Nls::getLocaleInfo