|
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) |
|
Definition at line 30 of file Locale.php.
◆ __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
- Given Locale
- HTTP Client
- Server Environment
- Framework Standard
- Parameters
-
string | Zend_Locale | $locale | (Optional) Locale for parsing input |
- Exceptions
-
Definition at line 1114 of file Locale.php.
◆ __toString()
Returns a string representation of the object Alias for toString
- Returns
- string
Definition at line 1145 of file Locale.php.
◆ clearCache()
static clearCache |
( |
|
$tag = null | ) |
|
|
static |
Clears all set cache data
- Parameters
-
string | $tag | Tag to clear when the default tag name is not used |
- Returns
- void
Definition at line 1854 of file Locale.php.
1856 #require_once 'Zend/Locale/Data.php';
◆ disableCache()
static disableCache |
( |
|
$flag | ) |
|
|
static |
Disables the set cache
- Parameters
-
boolean | $flag | True disables any set cache, default is false |
- Returns
- void
Definition at line 1866 of file Locale.php.
1868 #require_once 'Zend/Locale/Data.php'; static disableCache($flag)
◆ equals()
Returns true if both locales are equal
- Parameters
-
- Returns
- boolean
Definition at line 1443 of file Locale.php.
◆ 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
-
- Exceptions
-
- Returns
- string
Definition at line 1740 of file Locale.php.
1742 if ($locale ===
null) {
1743 #require_once 'Zend/Registry.php'; 1749 if ($locale ===
null) {
1757 if (empty($locale)) {
1758 #require_once 'Zend/Locale/Exception.php'; 1766 $locale = self::_prepareLocale($locale);
static isRegistered($index)
static isLocale($locale, $strict=false, $compatible=true)
static getLocaleToTerritory($territory)
◆ getAlias()
static getAlias |
( |
|
$locale | ) |
|
|
static |
Return an alias' actual locale.
- Parameters
-
- Returns
- string
Definition at line 2000 of file Locale.php.
2003 $locale = $locale->toString();
2006 if (isset(self::$_localeAliases[$locale]) ===
true) {
2007 return self::$_localeAliases[$locale];
2010 return (
string) $locale;
◆ getBrowser()
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.
1290 if (self::$_browser !==
null) {
1294 $httplanguages = getenv(
'HTTP_ACCEPT_LANGUAGE');
1295 if (empty($httplanguages) && array_key_exists(
'HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
1296 $httplanguages = $_SERVER[
'HTTP_ACCEPT_LANGUAGE'];
1299 $languages = array();
1300 if (empty($httplanguages)) {
1304 $accepted = preg_split(
'/,\s*/', $httplanguages);
1306 foreach ($accepted as $accept) {
1308 $result = preg_match(
'/^([a-z]{1,8}(?:[-_][a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i',
1315 if (isset($match[2]) ===
true) {
1316 $quality = (float) $match[2];
1321 $countrys = explode(
'-', $match[1]);
1322 $region = array_shift($countrys);
1324 $country2 = explode(
'_', $region);
1325 $region = array_shift($country2);
1327 foreach ($countrys as $country) {
1328 $languages[$region .
'_' . strtoupper($country)] = $quality;
1331 foreach ($country2 as $country) {
1332 $languages[$region .
'_' . strtoupper($country)] = $quality;
1335 if ((isset($languages[$region]) ===
false) || ($languages[$region] < $quality)) {
1336 $languages[$region] = $quality;
1340 self::$_browser = $languages;
◆ getCache()
Returns the set cache
- Returns
- Zend_Cache_Core The set cache
Definition at line 1808 of file Locale.php.
1810 #require_once 'Zend/Locale/Data.php';
◆ getCountryTranslation()
static getCountryTranslation |
( |
|
$value, |
|
|
|
$locale = null |
|
) |
| |
|
static |
Returns the localized country name
- Parameters
-
string | $value | Name 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.
1586 trigger_error(
"The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead", E_USER_NOTICE);
static getTranslation($value=null, $path=null, $locale=null)
◆ 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.
1509 trigger_error(
"The method getCountryTranslationList is deprecated. Use getTranslationList('territory', $locale, 2) instead", E_USER_NOTICE);
static getTranslationList($path=null, $locale=null, $value=null)
◆ getDefault()
Return the default locale
- Returns
- array Returns an array of all locale string
Definition at line 1155 of file Locale.php.
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);
1169 self::$_breakChain =
false;
static getOrder($order=null)
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ 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.
1231 if (self::$_environment !==
null) {
1235 #require_once 'Zend/Locale/Data/Translation.php'; 1237 $language = setlocale(LC_ALL, 0);
1238 $languages = explode(
';', $language);
1239 $languagearray = array();
1241 foreach ($languages as $locale) {
1242 if (strpos($locale,
'=') !==
false) {
1243 $language = substr($locale, strpos($locale,
'='));
1244 $language = substr($language, 1);
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,
'@'));
1254 $language = str_ireplace(
1260 $language = str_ireplace(
1266 if (isset(self::$_localeData[$language]) ===
true) {
1267 $languagearray[$language] = 1;
1268 if (strpos($language,
'_') !==
false) {
1269 $languagearray[substr($language, 0, strpos($language,
'_'))] = 1;
1275 self::$_environment = $languagearray;
1276 return $languagearray;
static $languageTranslation
static $regionTranslation
◆ getHttpCharset()
static getHttpCharset |
( |
| ) |
|
|
static |
Return the accepted charset of the client
- Returns
- string
Definition at line 1409 of file Locale.php.
1411 $httpcharsets = getenv(
'HTTP_ACCEPT_CHARSET');
1413 $charsets = array();
1414 if ($httpcharsets ===
false) {
1418 $accepted = preg_split(
'/,\s*/', $httpcharsets);
1419 foreach ($accepted as $accept) {
1420 if (empty($accept) ===
true) {
1424 if (strpos($accept,
';') !==
false) {
1425 $quality = (float) substr($accept, (strpos($accept,
'=') + 1));
1426 $pos = substr($accept, 0, strpos($accept,
';'));
1427 $charsets[
$pos] = $quality;
1430 $charsets[$accept] = $quality;
◆ getLanguage()
Returns the language part of the locale
- Returns
- string
Definition at line 1383 of file Locale.php.
1385 $locale = explode(
'_', $this->_locale);
◆ getLanguageTranslation()
static getLanguageTranslation |
( |
|
$value, |
|
|
|
$locale = null |
|
) |
| |
|
static |
Returns the localized language name
- Parameters
-
string | $value | Name to get detailed information about |
string | $locale | (Optional) Locale for language translation |
- Returns
- array
- Deprecated:
Definition at line 1556 of file Locale.php.
1558 trigger_error(
"The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead", E_USER_NOTICE);
static getTranslation($value=null, $path=null, $locale=null)
◆ 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.
1483 trigger_error(
"The method getLanguageTranslationList is deprecated. Use getTranslationList('language', $locale) instead", E_USER_NOTICE);
static getTranslationList($path=null, $locale=null, $value=null)
◆ getLocaleList()
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.
1795 $list = self::$_localeData;
1796 unset($list[
'root']);
1797 unset($list[
'auto']);
1798 unset($list[
'browser']);
1799 unset($list[
'environment']);
◆ getLocaleToTerritory()
static getLocaleToTerritory |
( |
|
$territory | ) |
|
|
static |
Returns the expected locale for a given territory
- Parameters
-
string | $territory | Territory 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.
1778 $territory = strtoupper($territory);
1779 if (array_key_exists($territory, self::$_territoryData)) {
1780 return self::$_territoryData[$territory];
◆ 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.
1961 self::$_breakChain =
true;
1966 self::$_breakChain =
true;
1971 self::$_breakChain =
true;
◆ 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.
1613 #require_once 'Zend/Locale/Data.php'; 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);
static getList($locale, $path, $value=false)
static findLocale($locale=null)
◆ getRegion()
Returns the region part of the locale if available
- Returns
- string|false - Regionstring
Definition at line 1394 of file Locale.php.
1396 $locale = explode(
'_', $this->_locale);
1397 if (isset($locale[1]) ===
true) {
◆ getScriptTranslation()
static getScriptTranslation |
( |
|
$value, |
|
|
|
$locale = null |
|
) |
| |
|
static |
Returns the localized script name
- Parameters
-
string | $value | Name to get detailed information about |
string | $locale | (Optional) locale for script translation |
- Returns
- array
- Deprecated:
Definition at line 1570 of file Locale.php.
1572 trigger_error(
"The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead", E_USER_NOTICE);
static getTranslation($value=null, $path=null, $locale=null)
◆ 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.
1496 trigger_error(
"The method getScriptTranslationList is deprecated. Use getTranslationList('script', $locale) instead", E_USER_NOTICE);
static getTranslationList($path=null, $locale=null, $value=null)
◆ getTerritoryTranslation()
static getTerritoryTranslation |
( |
|
$value, |
|
|
|
$locale = null |
|
) |
| |
|
static |
Returns the localized territory name All territories contains other countries.
- Parameters
-
string | $value | Name 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.
1601 trigger_error(
"The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead", E_USER_NOTICE);
static getTranslation($value=null, $path=null, $locale=null)
◆ 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.
1523 trigger_error(
"The method getTerritoryTranslationList is deprecated. Use getTranslationList('territory', $locale, 1) instead", E_USER_NOTICE);
static getTranslationList($path=null, $locale=null, $value=null)
◆ 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 | $value | Name 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.
1538 #require_once 'Zend/Locale/Data.php';
static getContent($locale, $path, $value=false)
static findLocale($locale=null)
◆ 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.
1464 #require_once 'Zend/Locale/Data.php'; 1467 if (empty(
$result) ===
true) {
static getList($locale, $path, $value=false)
static findLocale($locale=null)
◆ hasCache()
Returns true when a cache is set
- Returns
- boolean
Definition at line 1831 of file Locale.php.
1833 #require_once 'Zend/Locale/Data.php';
◆ isAlias()
static isAlias |
( |
|
$locale | ) |
|
|
static |
Is the given locale in the list of aliases?
- Parameters
-
- Returns
- boolean
Definition at line 1985 of file Locale.php.
1988 $locale = $locale->toString();
1991 return isset(self::$_localeAliases[$locale]);
◆ 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 | $locale | Locale 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.
1686 || (is_string($locale) && array_key_exists($locale, self::$_localeData))
1692 if (is_string($locale) && array_key_exists($locale, self::$_localeAliases)) {
1696 if (($locale ===
null) || (!is_string($locale) and !is_array($locale))) {
1701 $locale = self::_prepareLocale($locale, $strict);
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) {
1710 }
else if (!$strict) {
1711 $locale = explode(
'_', $locale);
1712 if (isset(self::$_localeData[$locale[0]]) ===
true) {
1717 if (isset(self::$_localeData[$locale]) ===
true) {
1719 }
else if (!$strict) {
1720 $locale = explode(
'_', $locale);
1721 if (isset(self::$_localeData[$locale[0]]) ===
true) {
◆ removeCache()
Removes any set cache
- Returns
- void
Definition at line 1842 of file Locale.php.
1844 #require_once 'Zend/Locale/Data.php';
◆ serialize()
Serialization Interface
- Returns
- string
Definition at line 1124 of file Locale.php.
◆ setCache()
Sets a cache
- Parameters
-
- Returns
- void
Definition at line 1820 of file Locale.php.
1822 #require_once 'Zend/Locale/Data.php';
static setCache(Zend_Cache_Core $cache)
◆ 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 | $locale | Locale to set |
float | $quality | The quality to set from 0 to 1 |
- Exceptions
-
- Returns
- void
Definition at line 1187 of file Locale.php.
1189 if (($locale ===
'auto') or ($locale ===
'root') or ($locale ===
'default') or
1190 ($locale ===
'environment') or ($locale ===
'browser')) {
1191 #require_once 'Zend/Locale/Exception.php'; 1195 if (($quality < 0.1) or ($quality > 100)) {
1196 #require_once 'Zend/Locale/Exception.php'; 1204 $locale = self::_prepareLocale($locale);
1205 if (isset(self::$_localeData[(
string) $locale]) ===
true) {
1208 $elocale = explode(
'_', (
string) $locale);
1209 if (isset(self::$_localeData[$elocale[0]]) ===
true) {
1212 #require_once 'Zend/Locale/Exception.php'; 1213 throw new Zend_Locale_Exception(
"Unknown locale '" . (
string) $locale .
"' can not be set as default!");
◆ 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.
1352 $locale = self::_prepareLocale($locale);
1354 if (isset(self::$_localeData[(
string) $locale]) ===
false) {
1356 if (isset(self::$_localeAliases[$locale]) ===
true) {
1357 $this->_locale = $locale;
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);
1368 if (isset(self::$_localeData[(
string) $region]) ===
true) {
1369 $this->_locale = $region;
1371 $this->_locale =
'root';
1374 $this->_locale = $locale;
◆ toString()
Returns a string representation of the object
- Returns
- string
Definition at line 1134 of file Locale.php.
◆ $_auto
◆ $_browser
◆ $_default
$_default = array('en' => true) |
|
staticprotected |
◆ $_environment
◆ $_locale
◆ $compatibilityMode
$compatibilityMode = false |
|
static |
◆ BROWSER
const BROWSER = 'browser' |
◆ ENVIRONMENT
const ENVIRONMENT = 'environment' |
◆ ZFDEFAULT
const ZFDEFAULT = 'default' |
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Locale.php