Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Attributes | Static Protected Attributes
Zend_Locale Class Reference

Public Member Functions

 __construct ($locale=null)
 
 serialize ()
 
 toString ()
 
 __toString ()
 
 setLocale ($locale=null)
 
 getLanguage ()
 
 getRegion ()
 
 equals (Zend_Locale $object)
 

Static Public Member Functions

static getDefault ()
 
static setDefault ($locale, $quality=1)
 
static getEnvironment ()
 
static getBrowser ()
 
static getHttpCharset ()
 
static getTranslationList ($path=null, $locale=null, $value=null)
 
static getLanguageTranslationList ($locale=null)
 
static getScriptTranslationList ($locale=null)
 
static getCountryTranslationList ($locale=null)
 
static getTerritoryTranslationList ($locale=null)
 
static getTranslation ($value=null, $path=null, $locale=null)
 
static getLanguageTranslation ($value, $locale=null)
 
static getScriptTranslation ($value, $locale=null)
 
static getCountryTranslation ($value, $locale=null)
 
static getTerritoryTranslation ($value, $locale=null)
 
static getQuestion ($locale=null)
 
static isLocale ($locale, $strict=false, $compatible=true)
 
static findLocale ($locale=null)
 
static getLocaleToTerritory ($territory)
 
static getLocaleList ()
 
static getCache ()
 
static setCache (Zend_Cache_Core $cache)
 
static hasCache ()
 
static removeCache ()
 
static clearCache ($tag=null)
 
static disableCache ($flag)
 
static getOrder ($order=null)
 
static isAlias ($locale)
 
static getAlias ($locale)
 

Data Fields

const BROWSER = 'browser'
 
const ENVIRONMENT = 'environment'
 
const ZFDEFAULT = 'default'
 

Static Public Attributes

static $compatibilityMode = false
 

Protected Attributes

 $_locale
 

Static Protected Attributes

static $_auto
 
static $_browser
 
static $_environment
 
static $_default = array('en' => true)
 

Detailed Description

Definition at line 30 of file Locale.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $locale = null)

Generates a locale object If no locale is given a automatic search is done Then the most probable locale will be automatically set Search order is

  1. Given Locale
  2. HTTP Client
  3. Server Environment
  4. Framework Standard
Parameters
string | Zend_Locale$locale(Optional) Locale for parsing input
Exceptions
Zend_Locale_ExceptionWhen autodetection has been failed

Definition at line 1114 of file Locale.php.

1115  {
1116  $this->setLocale($locale);
1117  }
setLocale($locale=null)
Definition: Locale.php:1350

Member Function Documentation

◆ __toString()

__toString ( )

Returns a string representation of the object Alias for toString

Returns
string

Definition at line 1145 of file Locale.php.

1146  {
1147  return $this->toString();
1148  }

◆ clearCache()

static clearCache (   $tag = null)
static

Clears all set cache data

Parameters
string$tagTag to clear when the default tag name is not used
Returns
void

Definition at line 1854 of file Locale.php.

1855  {
1856  #require_once 'Zend/Locale/Data.php';
1858  }
static clearCache()
Definition: Data.php:1562

◆ disableCache()

static disableCache (   $flag)
static

Disables the set cache

Parameters
boolean$flagTrue disables any set cache, default is false
Returns
void

Definition at line 1866 of file Locale.php.

1867  {
1868  #require_once 'Zend/Locale/Data.php';
1870  }
static disableCache($flag)
Definition: Data.php:1576

◆ equals()

equals ( Zend_Locale  $object)

Returns true if both locales are equal

Parameters
Zend_Locale$objectLocale to check for equality
Returns
boolean

Definition at line 1443 of file Locale.php.

1444  {
1445  if ($object->toString() === $this->toString()) {
1446  return true;
1447  }
1448 
1449  return false;
1450  }

◆ findLocale()

static findLocale (   $locale = null)
static

Finds the proper locale based on the input Checks if it exists, degrades it when necessary Detects registry locale and when all fails tries to detect a automatic locale Returns the found locale as string

Parameters
string$locale
Exceptions
Zend_Locale_ExceptionWhen the given locale is no locale or the autodetection fails
Returns
string

Definition at line 1740 of file Locale.php.

1741  {
1742  if ($locale === null) {
1743  #require_once 'Zend/Registry.php';
1744  if (Zend_Registry::isRegistered('Zend_Locale')) {
1745  $locale = Zend_Registry::get('Zend_Locale');
1746  }
1747  }
1748 
1749  if ($locale === null) {
1750  $locale = new Zend_Locale();
1751  }
1752 
1753  if (!Zend_Locale::isLocale($locale, true, false)) {
1754  if (!Zend_Locale::isLocale($locale, false, false)) {
1755  $locale = Zend_Locale::getLocaleToTerritory($locale);
1756 
1757  if (empty($locale)) {
1758  #require_once 'Zend/Locale/Exception.php';
1759  throw new Zend_Locale_Exception("The locale '$locale' is no known locale");
1760  }
1761  } else {
1762  $locale = new Zend_Locale($locale);
1763  }
1764  }
1765 
1766  $locale = self::_prepareLocale($locale);
1767  return $locale;
1768  }
static isRegistered($index)
Definition: Registry.php:178
static isLocale($locale, $strict=false, $compatible=true)
Definition: Locale.php:1683
static getLocaleToTerritory($territory)
Definition: Locale.php:1776
static get($index)
Definition: Registry.php:141

◆ getAlias()

static getAlias (   $locale)
static

Return an alias' actual locale.

Parameters
string | Zend_Locale$localeLocale to work on
Returns
string

Definition at line 2000 of file Locale.php.

2001  {
2002  if ($locale instanceof Zend_Locale) {
2003  $locale = $locale->toString();
2004  }
2005 
2006  if (isset(self::$_localeAliases[$locale]) === true) {
2007  return self::$_localeAliases[$locale];
2008  }
2009 
2010  return (string) $locale;
2011  }

◆ getBrowser()

static getBrowser ( )
static

Return an array of all accepted languages of the client Expects RFC compilant Header !!

The notation can be : de,en-UK-US;q=0.5,fr-FR;q=0.2

Returns
array - list of accepted languages including quality

Definition at line 1288 of file Locale.php.

1289  {
1290  if (self::$_browser !== null) {
1291  return self::$_browser;
1292  }
1293 
1294  $httplanguages = getenv('HTTP_ACCEPT_LANGUAGE');
1295  if (empty($httplanguages) && array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
1296  $httplanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
1297  }
1298 
1299  $languages = array();
1300  if (empty($httplanguages)) {
1301  return $languages;
1302  }
1303 
1304  $accepted = preg_split('/,\s*/', $httplanguages);
1305 
1306  foreach ($accepted as $accept) {
1307  $match = null;
1308  $result = preg_match('/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
1309  $accept, $match);
1310 
1311  if ($result < 1) {
1312  continue;
1313  }
1314 
1315  if (isset($match[2]) === true) {
1316  $quality = (float) $match[2];
1317  } else {
1318  $quality = 1.0;
1319  }
1320 
1321  $countrys = explode('-', $match[1]);
1322  $region = array_shift($countrys);
1323 
1324  $country2 = explode('_', $region);
1325  $region = array_shift($country2);
1326 
1327  foreach ($countrys as $country) {
1328  $languages[$region . '_' . strtoupper($country)] = $quality;
1329  }
1330 
1331  foreach ($country2 as $country) {
1332  $languages[$region . '_' . strtoupper($country)] = $quality;
1333  }
1334 
1335  if ((isset($languages[$region]) === false) || ($languages[$region] < $quality)) {
1336  $languages[$region] = $quality;
1337  }
1338  }
1339 
1340  self::$_browser = $languages;
1341  return $languages;
1342  }
static $_browser
Definition: Locale.php:1085

◆ getCache()

static getCache ( )
static

Returns the set cache

Returns
Zend_Cache_Core The set cache

Definition at line 1808 of file Locale.php.

1809  {
1810  #require_once 'Zend/Locale/Data.php';
1811  return Zend_Locale_Data::getCache();
1812  }
static getCache()
Definition: Data.php:1517

◆ getCountryTranslation()

static getCountryTranslation (   $value,
  $locale = null 
)
static

Returns the localized country name

Parameters
string$valueName to get detailed information about
string | Zend_Locale$locale(Optional) Locale for country translation
Returns
array
Deprecated:

Definition at line 1584 of file Locale.php.

1585  {
1586  trigger_error("The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead", E_USER_NOTICE);
1587  return self::getTranslation($value, 'country', $locale);
1588  }
static getTranslation($value=null, $path=null, $locale=null)
Definition: Locale.php:1536
$value
Definition: gender.phtml:16

◆ getCountryTranslationList()

static getCountryTranslationList (   $locale = null)
static

Returns an array with the name of all countries translated to the given language

Parameters
string | Zend_Locale$locale(Optional) Locale for country translation
Returns
array
Deprecated:

Definition at line 1507 of file Locale.php.

1508  {
1509  trigger_error("The method getCountryTranslationList is deprecated. Use getTranslationList('territory', $locale, 2) instead", E_USER_NOTICE);
1510  return self::getTranslationList('territory', $locale, 2);
1511  }
static getTranslationList($path=null, $locale=null, $value=null)
Definition: Locale.php:1462

◆ getDefault()

static getDefault ( )
static

Return the default locale

Returns
array Returns an array of all locale string

Definition at line 1155 of file Locale.php.

1156  {
1157  if ((self::$compatibilityMode === true) or (func_num_args() > 0)) {
1158  if (!self::$_breakChain) {
1159  self::$_breakChain = true;
1160  trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
1161  $params = func_get_args();
1162  $param = null;
1163  if (isset($params[0])) {
1164  $param = $params[0];
1165  }
1166  return self::getOrder($param);
1167  }
1168 
1169  self::$_breakChain = false;
1170  }
1171 
1172  return self::$_default;
1173  }
static $_default
Definition: Locale.php:1099
static getOrder($order=null)
Definition: Locale.php:1957
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getEnvironment()

static getEnvironment ( )
static

Expects the Systems standard locale

For Windows: f.e.: LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C would be recognised as de_AT

Returns
array

Definition at line 1229 of file Locale.php.

1230  {
1231  if (self::$_environment !== null) {
1232  return self::$_environment;
1233  }
1234 
1235  #require_once 'Zend/Locale/Data/Translation.php';
1236 
1237  $language = setlocale(LC_ALL, 0);
1238  $languages = explode(';', $language);
1239  $languagearray = array();
1240 
1241  foreach ($languages as $locale) {
1242  if (strpos($locale, '=') !== false) {
1243  $language = substr($locale, strpos($locale, '='));
1244  $language = substr($language, 1);
1245  }
1246 
1247  if ($language !== 'C') {
1248  if (strpos($language, '.') !== false) {
1249  $language = substr($language, 0, strpos($language, '.'));
1250  } else if (strpos($language, '@') !== false) {
1251  $language = substr($language, 0, strpos($language, '@'));
1252  }
1253 
1254  $language = str_ireplace(
1257  (string) $language
1258  );
1259 
1260  $language = str_ireplace(
1263  $language
1264  );
1265 
1266  if (isset(self::$_localeData[$language]) === true) {
1267  $languagearray[$language] = 1;
1268  if (strpos($language, '_') !== false) {
1269  $languagearray[substr($language, 0, strpos($language, '_'))] = 1;
1270  }
1271  }
1272  }
1273  }
1274 
1275  self::$_environment = $languagearray;
1276  return $languagearray;
1277  }
static $_environment
Definition: Locale.php:1092

◆ getHttpCharset()

static getHttpCharset ( )
static

Return the accepted charset of the client

Returns
string

Definition at line 1409 of file Locale.php.

1410  {
1411  $httpcharsets = getenv('HTTP_ACCEPT_CHARSET');
1412 
1413  $charsets = array();
1414  if ($httpcharsets === false) {
1415  return $charsets;
1416  }
1417 
1418  $accepted = preg_split('/,\s*/', $httpcharsets);
1419  foreach ($accepted as $accept) {
1420  if (empty($accept) === true) {
1421  continue;
1422  }
1423 
1424  if (strpos($accept, ';') !== false) {
1425  $quality = (float) substr($accept, (strpos($accept, '=') + 1));
1426  $pos = substr($accept, 0, strpos($accept, ';'));
1427  $charsets[$pos] = $quality;
1428  } else {
1429  $quality = 1.0;
1430  $charsets[$accept] = $quality;
1431  }
1432  }
1433 
1434  return $charsets;
1435  }
$pos
Definition: list.phtml:42

◆ getLanguage()

getLanguage ( )

Returns the language part of the locale

Returns
string

Definition at line 1383 of file Locale.php.

1384  {
1385  $locale = explode('_', $this->_locale);
1386  return $locale[0];
1387  }

◆ getLanguageTranslation()

static getLanguageTranslation (   $value,
  $locale = null 
)
static

Returns the localized language name

Parameters
string$valueName to get detailed information about
string$locale(Optional) Locale for language translation
Returns
array
Deprecated:

Definition at line 1556 of file Locale.php.

1557  {
1558  trigger_error("The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead", E_USER_NOTICE);
1559  return self::getTranslation($value, 'language', $locale);
1560  }
static getTranslation($value=null, $path=null, $locale=null)
Definition: Locale.php:1536
$value
Definition: gender.phtml:16

◆ getLanguageTranslationList()

static getLanguageTranslationList (   $locale = null)
static

Returns an array with the name of all languages translated to the given language

Parameters
string | Zend_Locale$locale(Optional) Locale for language translation
Returns
array
Deprecated:

Definition at line 1481 of file Locale.php.

1482  {
1483  trigger_error("The method getLanguageTranslationList is deprecated. Use getTranslationList('language', $locale) instead", E_USER_NOTICE);
1484  return self::getTranslationList('language', $locale);
1485  }
static getTranslationList($path=null, $locale=null, $value=null)
Definition: Locale.php:1462

◆ getLocaleList()

static getLocaleList ( )
static

Returns a list of all known locales where the locale is the key Only real locales are returned, the internal locales 'root', 'auto', 'browser' and 'environment' are suppressed

Returns
array List of all Locales

Definition at line 1793 of file Locale.php.

1794  {
1795  $list = self::$_localeData;
1796  unset($list['root']);
1797  unset($list['auto']);
1798  unset($list['browser']);
1799  unset($list['environment']);
1800  return $list;
1801  }

◆ getLocaleToTerritory()

static getLocaleToTerritory (   $territory)
static

Returns the expected locale for a given territory

Parameters
string$territoryTerritory for which the locale is being searched
Returns
string|null Locale string or null when no locale has been found

Definition at line 1776 of file Locale.php.

1777  {
1778  $territory = strtoupper($territory);
1779  if (array_key_exists($territory, self::$_territoryData)) {
1780  return self::$_territoryData[$territory];
1781  }
1782 
1783  return null;
1784  }

◆ getOrder()

static getOrder (   $order = null)
static

Search the locale automatically and return all used locales ordered by quality

Standard Searchorder is Browser, Environment, Default

Parameters
string$searchorder(Optional) Searchorder
Returns
array Returns an array of all detected locales

Definition at line 1957 of file Locale.php.

1958  {
1959  switch ($order) {
1960  case self::ENVIRONMENT:
1961  self::$_breakChain = true;
1963  break;
1964 
1965  case self::ZFDEFAULT:
1966  self::$_breakChain = true;
1968  break;
1969 
1970  default:
1971  self::$_breakChain = true;
1973  break;
1974  }
1975 
1976  return $languages;
1977  }
static getBrowser()
Definition: Locale.php:1288
$order
Definition: order.php:55
const ENVIRONMENT
Definition: Locale.php:1048
static getEnvironment()
Definition: Locale.php:1229
const ZFDEFAULT
Definition: Locale.php:1049
static getDefault()
Definition: Locale.php:1155

◆ getQuestion()

static getQuestion (   $locale = null)
static

Returns an array with translated yes strings

Parameters
string | Zend_Locale$locale(Optional) Locale for language translation (defaults to $this locale)
Returns
array

Definition at line 1611 of file Locale.php.

1612  {
1613  #require_once 'Zend/Locale/Data.php';
1614  $locale = self::findLocale($locale);
1615  $quest = Zend_Locale_Data::getList($locale, 'question');
1616  $yes = explode(':', $quest['yes']);
1617  $no = explode(':', $quest['no']);
1618  $quest['yes'] = $yes[0];
1619  $quest['yesarray'] = $yes;
1620  $quest['no'] = $no[0];
1621  $quest['noarray'] = $no;
1622  $quest['yesexpr'] = self::_prepareQuestionString($yes);
1623  $quest['noexpr'] = self::_prepareQuestionString($no);
1624 
1625  return $quest;
1626  }
static getList($locale, $path, $value=false)
Definition: Data.php:318
static findLocale($locale=null)
Definition: Locale.php:1740

◆ getRegion()

getRegion ( )

Returns the region part of the locale if available

Returns
string|false - Regionstring

Definition at line 1394 of file Locale.php.

1395  {
1396  $locale = explode('_', $this->_locale);
1397  if (isset($locale[1]) === true) {
1398  return $locale[1];
1399  }
1400 
1401  return false;
1402  }

◆ getScriptTranslation()

static getScriptTranslation (   $value,
  $locale = null 
)
static

Returns the localized script name

Parameters
string$valueName to get detailed information about
string$locale(Optional) locale for script translation
Returns
array
Deprecated:

Definition at line 1570 of file Locale.php.

1571  {
1572  trigger_error("The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead", E_USER_NOTICE);
1573  return self::getTranslation($value, 'script', $locale);
1574  }
static getTranslation($value=null, $path=null, $locale=null)
Definition: Locale.php:1536
$value
Definition: gender.phtml:16

◆ getScriptTranslationList()

static getScriptTranslationList (   $locale = null)
static

Returns an array with the name of all scripts translated to the given language

Parameters
string | Zend_Locale$locale(Optional) Locale for script translation
Returns
array
Deprecated:

Definition at line 1494 of file Locale.php.

1495  {
1496  trigger_error("The method getScriptTranslationList is deprecated. Use getTranslationList('script', $locale) instead", E_USER_NOTICE);
1497  return self::getTranslationList('script', $locale);
1498  }
static getTranslationList($path=null, $locale=null, $value=null)
Definition: Locale.php:1462

◆ getTerritoryTranslation()

static getTerritoryTranslation (   $value,
  $locale = null 
)
static

Returns the localized territory name All territories contains other countries.

Parameters
string$valueName to get detailed information about
string | Zend_Locale$locale(Optional) Locale for territory translation
Returns
array
Deprecated:

Definition at line 1599 of file Locale.php.

1600  {
1601  trigger_error("The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead", E_USER_NOTICE);
1602  return self::getTranslation($value, 'territory', $locale);
1603  }
static getTranslation($value=null, $path=null, $locale=null)
Definition: Locale.php:1536
$value
Definition: gender.phtml:16

◆ getTerritoryTranslationList()

static getTerritoryTranslationList (   $locale = null)
static

Returns an array with the name of all territories translated to the given language All territories contains other countries.

Parameters
string | Zend_Locale$locale(Optional) Locale for territory translation
Returns
array
Deprecated:

Definition at line 1521 of file Locale.php.

1522  {
1523  trigger_error("The method getTerritoryTranslationList is deprecated. Use getTranslationList('territory', $locale, 1) instead", E_USER_NOTICE);
1524  return self::getTranslationList('territory', $locale, 1);
1525  }
static getTranslationList($path=null, $locale=null, $value=null)
Definition: Locale.php:1462

◆ getTranslation()

static getTranslation (   $value = null,
  $path = null,
  $locale = null 
)
static

Returns a localized information string, supported are several types of informations. For detailed information about the types look into the documentation

Parameters
string$valueName to get detailed information about
string$path(Optional) Type of information to return
string | Zend_Locale$locale(Optional) Locale|Language for which this informations should be returned
Returns
string|false The wished information in the given language

Definition at line 1536 of file Locale.php.

1537  {
1538  #require_once 'Zend/Locale/Data.php';
1539  $locale = self::findLocale($locale);
1541  if (empty($result) === true && '0' !== $result) {
1542  return false;
1543  }
1544 
1545  return $result;
1546  }
static getContent($locale, $path, $value=false)
Definition: Data.php:968
$value
Definition: gender.phtml:16
static findLocale($locale=null)
Definition: Locale.php:1740

◆ getTranslationList()

static getTranslationList (   $path = null,
  $locale = null,
  $value = null 
)
static

Returns localized informations as array, supported are several types of informations. For detailed information about the types look into the documentation

Parameters
string$path(Optional) Type of information to return
string | Zend_Locale$locale(Optional) Locale|Language for which this informations should be returned
string$value(Optional) Value for detail list
Returns
array Array with the wished information in the given language

Definition at line 1462 of file Locale.php.

1463  {
1464  #require_once 'Zend/Locale/Data.php';
1465  $locale = self::findLocale($locale);
1467  if (empty($result) === true) {
1468  return false;
1469  }
1470 
1471  return $result;
1472  }
static getList($locale, $path, $value=false)
Definition: Data.php:318
$value
Definition: gender.phtml:16
static findLocale($locale=null)
Definition: Locale.php:1740

◆ hasCache()

static hasCache ( )
static

Returns true when a cache is set

Returns
boolean

Definition at line 1831 of file Locale.php.

1832  {
1833  #require_once 'Zend/Locale/Data.php';
1834  return Zend_Locale_Data::hasCache();
1835  }
static hasCache()
Definition: Data.php:1538

◆ isAlias()

static isAlias (   $locale)
static

Is the given locale in the list of aliases?

Parameters
string | Zend_Locale$localeLocale to work on
Returns
boolean

Definition at line 1985 of file Locale.php.

1986  {
1987  if ($locale instanceof Zend_Locale) {
1988  $locale = $locale->toString();
1989  }
1990 
1991  return isset(self::$_localeAliases[$locale]);
1992  }

◆ isLocale()

static isLocale (   $locale,
  $strict = false,
  $compatible = true 
)
static

Checks if a locale identifier is a real locale or not Examples: "en_XX" refers to "en", which returns true "XX_yy" refers to "root", which returns false

Parameters
string | Zend_Locale$localeLocale to check for
boolean$strict(Optional) If true, no rerouting will be done when checking
boolean$compatible(DEPRECATED) Only for internal usage, brakes compatibility mode
Returns
boolean If the locale is known dependend on the settings

Definition at line 1683 of file Locale.php.

1684  {
1685  if (($locale instanceof Zend_Locale)
1686  || (is_string($locale) && array_key_exists($locale, self::$_localeData))
1687  ) {
1688  return true;
1689  }
1690 
1691  // Is it an alias?
1692  if (is_string($locale) && array_key_exists($locale, self::$_localeAliases)) {
1693  return true;
1694  }
1695 
1696  if (($locale === null) || (!is_string($locale) and !is_array($locale))) {
1697  return false;
1698  }
1699 
1700  try {
1701  $locale = self::_prepareLocale($locale, $strict);
1702  } catch (Zend_Locale_Exception $e) {
1703  return false;
1704  }
1705 
1706  if (($compatible === true) and (self::$compatibilityMode === true)) {
1707  trigger_error('You are running Zend_Locale in compatibility mode... please migrate your scripts', E_USER_NOTICE);
1708  if (isset(self::$_localeData[$locale]) === true) {
1709  return $locale;
1710  } else if (!$strict) {
1711  $locale = explode('_', $locale);
1712  if (isset(self::$_localeData[$locale[0]]) === true) {
1713  return $locale[0];
1714  }
1715  }
1716  } else {
1717  if (isset(self::$_localeData[$locale]) === true) {
1718  return true;
1719  } else if (!$strict) {
1720  $locale = explode('_', $locale);
1721  if (isset(self::$_localeData[$locale[0]]) === true) {
1722  return true;
1723  }
1724  }
1725  }
1726 
1727  return false;
1728  }

◆ removeCache()

static removeCache ( )
static

Removes any set cache

Returns
void

Definition at line 1842 of file Locale.php.

1843  {
1844  #require_once 'Zend/Locale/Data.php';
1846  }
static removeCache()
Definition: Data.php:1552

◆ serialize()

serialize ( )

Serialization Interface

Returns
string

Definition at line 1124 of file Locale.php.

1125  {
1126  return serialize($this);
1127  }

◆ setCache()

static setCache ( Zend_Cache_Core  $cache)
static

Sets a cache

Parameters
Zend_Cache_Core$cacheCache to set
Returns
void

Definition at line 1820 of file Locale.php.

1821  {
1822  #require_once 'Zend/Locale/Data.php';
1824  }
static setCache(Zend_Cache_Core $cache)
Definition: Data.php:1527

◆ setDefault()

static setDefault (   $locale,
  $quality = 1 
)
static

Sets a new default locale which will be used when no locale can be detected If provided you can set a quality between 0 and 1 (or 2 and 100) which represents the percent of quality the browser requested within HTTP

Parameters
string | Zend_Locale$localeLocale to set
float$qualityThe quality to set from 0 to 1
Exceptions
Zend_Locale_ExceptionWhen a autolocale was given
Zend_Locale_ExceptionWhen a unknown locale was given
Returns
void

Definition at line 1187 of file Locale.php.

1188  {
1189  if (($locale === 'auto') or ($locale === 'root') or ($locale === 'default') or
1190  ($locale === 'environment') or ($locale === 'browser')) {
1191  #require_once 'Zend/Locale/Exception.php';
1192  throw new Zend_Locale_Exception('Only full qualified locales can be used as default!');
1193  }
1194 
1195  if (($quality < 0.1) or ($quality > 100)) {
1196  #require_once 'Zend/Locale/Exception.php';
1197  throw new Zend_Locale_Exception("Quality must be between 0.1 and 100");
1198  }
1199 
1200  if ($quality > 1) {
1201  $quality /= 100;
1202  }
1203 
1204  $locale = self::_prepareLocale($locale);
1205  if (isset(self::$_localeData[(string) $locale]) === true) {
1206  self::$_default = array((string) $locale => $quality);
1207  } else {
1208  $elocale = explode('_', (string) $locale);
1209  if (isset(self::$_localeData[$elocale[0]]) === true) {
1210  self::$_default = array($elocale[0] => $quality);
1211  } else {
1212  #require_once 'Zend/Locale/Exception.php';
1213  throw new Zend_Locale_Exception("Unknown locale '" . (string) $locale . "' can not be set as default!");
1214  }
1215  }
1216 
1217  self::$_auto = self::getBrowser() + self::getEnvironment() + self::getDefault();
1218  }
$_default
Definition: radio.phtml:13
static getBrowser()
Definition: Locale.php:1288
static getEnvironment()
Definition: Locale.php:1229
static getDefault()
Definition: Locale.php:1155

◆ setLocale()

setLocale (   $locale = null)

Sets a new locale

Parameters
string | Zend_Locale$locale(Optional) New locale to set
Returns
void

Definition at line 1350 of file Locale.php.

1351  {
1352  $locale = self::_prepareLocale($locale);
1353 
1354  if (isset(self::$_localeData[(string) $locale]) === false) {
1355  // Is it an alias? If so, we can use this locale
1356  if (isset(self::$_localeAliases[$locale]) === true) {
1357  $this->_locale = $locale;
1358  return;
1359  }
1360 
1361  $region = substr((string) $locale, 0, 3);
1362  if (isset($region[2]) === true) {
1363  if (($region[2] === '_') or ($region[2] === '-')) {
1364  $region = substr($region, 0, 2);
1365  }
1366  }
1367 
1368  if (isset(self::$_localeData[(string) $region]) === true) {
1369  $this->_locale = $region;
1370  } else {
1371  $this->_locale = 'root';
1372  }
1373  } else {
1374  $this->_locale = $locale;
1375  }
1376  }

◆ toString()

toString ( )

Returns a string representation of the object

Returns
string

Definition at line 1134 of file Locale.php.

1135  {
1136  return (string) $this->_locale;
1137  }

Field Documentation

◆ $_auto

$_auto
staticprotected

Definition at line 1078 of file Locale.php.

◆ $_browser

$_browser
staticprotected

Definition at line 1085 of file Locale.php.

◆ $_default

$_default = array('en' => true)
staticprotected

Definition at line 1099 of file Locale.php.

◆ $_environment

$_environment
staticprotected

Definition at line 1092 of file Locale.php.

◆ $_locale

$_locale
protected

Definition at line 1071 of file Locale.php.

◆ $compatibilityMode

$compatibilityMode = false
static

Definition at line 1057 of file Locale.php.

◆ BROWSER

const BROWSER = 'browser'

Autosearch constants

Definition at line 1047 of file Locale.php.

◆ ENVIRONMENT

const ENVIRONMENT = 'environment'

Definition at line 1048 of file Locale.php.

◆ ZFDEFAULT

const ZFDEFAULT = 'default'

Definition at line 1049 of file Locale.php.


The documentation for this class was generated from the following file: