38 private static $_localeAliases = array(
39 'az_AZ' =>
'az_Latn_AZ',
40 'bs_BA' =>
'bs_Latn_BA',
41 'ha_GH' =>
'ha_Latn_GH',
42 'ha_NE' =>
'ha_Latn_NE',
43 'ha_NG' =>
'ha_Latn_NG',
44 'kk_KZ' =>
'kk_Cyrl_KZ',
45 'ks_IN' =>
'ks_Arab_IN',
46 'mn_MN' =>
'mn_Cyrl_MN',
47 'ms_BN' =>
'ms_Latn_BN',
48 'ms_MY' =>
'ms_Latn_MY',
49 'ms_SG' =>
'ms_Latn_SG',
50 'pa_IN' =>
'pa_Guru_IN',
51 'pa_PK' =>
'pa_Arab_PK',
52 'shi_MA' =>
'shi_Latn_MA',
53 'sr_BA' =>
'sr_Latn_BA',
54 'sr_ME' =>
'sr_Latn_ME',
55 'sr_RS' =>
'sr_Latn_RS',
56 'sr_XK' =>
'sr_Latn_XK',
57 'tg_TJ' =>
'tg_Cyrl_TJ',
58 'tzm_MA' =>
'tzm_Latn_MA',
59 'uz_AF' =>
'uz_Arab_AF',
60 'uz_UZ' =>
'uz_Latn_UZ',
61 'vai_LR' =>
'vai_Latn_LR',
62 'zh_CN' =>
'zh_Hans_CN',
63 'zh_HK' =>
'zh_Hant_HK',
64 'zh_MO' =>
'zh_Hans_MO',
65 'zh_SG' =>
'zh_Hans_SG',
66 'zh_TW' =>
'zh_Hant_TW',
74 private static $_localeData = array(
126 'az_Cyrl_AZ' =>
true,
128 'az_Latn_AZ' =>
true,
153 'bs_Cyrl_BA' =>
true,
155 'bs_Latn_BA' =>
true,
161 'ca_ES_VALENCIA' =>
true,
221 'en_Dsrt_US' =>
true,
287 'en_US_POSIX' =>
true,
413 'ha_Latn_GH' =>
true,
414 'ha_Latn_NE' =>
true,
415 'ha_Latn_NG' =>
true,
465 'kk_Cyrl_KZ' =>
true,
483 'ks_Arab_IN' =>
true,
494 'ky_Cyrl_KG' =>
true,
537 'mn_Cyrl_MN' =>
true,
542 'ms_Latn_BN' =>
true,
543 'ms_Latn_MY' =>
true,
544 'ms_Latn_SG' =>
true,
594 'pa_Arab_PK' =>
true,
596 'pa_Guru_IN' =>
true,
649 'shi_Latn_MA' =>
true,
651 'shi_Tfng_MA' =>
true,
671 'sr_Cyrl_BA' =>
true,
672 'sr_Cyrl_ME' =>
true,
673 'sr_Cyrl_RS' =>
true,
674 'sr_Cyrl_XK' =>
true,
676 'sr_Latn_BA' =>
true,
677 'sr_Latn_ME' =>
true,
678 'sr_Latn_RS' =>
true,
679 'sr_Latn_XK' =>
true,
710 'tg_Cyrl_TJ' =>
true,
732 'tzm_Latn_MA' =>
true,
735 'ug_Arab_CN' =>
true,
743 'uz_Arab_AF' =>
true,
745 'uz_Cyrl_UZ' =>
true,
747 'uz_Latn_UZ' =>
true,
750 'vai_Latn_LR' =>
true,
752 'vai_Vaii_LR' =>
true,
778 'zh_Hans_CN' =>
true,
779 'zh_Hans_HK' =>
true,
780 'zh_Hans_MO' =>
true,
781 'zh_Hans_SG' =>
true,
783 'zh_Hant_HK' =>
true,
784 'zh_Hant_MO' =>
true,
785 'zh_Hant_TW' =>
true,
795 private static $_territoryData = array(
812 'AZ' =>
'az_Latn_AZ',
843 'CN' =>
'zh_Hans_CN',
889 'HK' =>
'zh_Hant_HK',
910 'KG' =>
'ky_Cyrl_KG',
934 'ME' =>
'sr_Latn_ME',
941 'MN' =>
'mn_Cyrl_MN',
942 'MO' =>
'zh_Hant_MO',
956 'NE' =>
'ha_Latn_NE',
984 'RS' =>
'sr_Cyrl_RS',
1011 'TJ' =>
'tg_Cyrl_TJ',
1020 'TW' =>
'zh_Hant_TW',
1027 'UZ' =>
'uz_Cyrl_UZ',
1064 private static $_breakChain =
false;
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;
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!");
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;
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;
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;
1385 $locale = explode(
'_', $this->_locale);
1396 $locale = explode(
'_', $this->_locale);
1397 if (isset($locale[1]) ===
true) {
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;
1464 #require_once 'Zend/Locale/Data.php'; 1467 if (empty(
$result) ===
true) {
1483 trigger_error(
"The method getLanguageTranslationList is deprecated. Use getTranslationList('language', $locale) instead", E_USER_NOTICE);
1496 trigger_error(
"The method getScriptTranslationList is deprecated. Use getTranslationList('script', $locale) instead", E_USER_NOTICE);
1509 trigger_error(
"The method getCountryTranslationList is deprecated. Use getTranslationList('territory', $locale, 2) instead", E_USER_NOTICE);
1523 trigger_error(
"The method getTerritoryTranslationList is deprecated. Use getTranslationList('territory', $locale, 1) instead", E_USER_NOTICE);
1538 #require_once 'Zend/Locale/Data.php'; 1558 trigger_error(
"The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead", E_USER_NOTICE);
1572 trigger_error(
"The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead", E_USER_NOTICE);
1586 trigger_error(
"The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead", E_USER_NOTICE);
1601 trigger_error(
"The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead", E_USER_NOTICE);
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);
1634 private static function _prepareQuestionString($input)
1637 if (is_array($input) ===
true) {
1640 foreach ($input as
$row) {
1648 if (strlen(
$row) > 2) {
1652 foreach (str_split(
$row, 1) as $char) {
1653 $regex .=
'[' . $char;
1654 $regex .= strtoupper($char) .
']';
1655 if ($one ===
true) {
1661 if ($one ===
false) {
1683 public static function isLocale($locale, $strict =
false, $compatible =
true)
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) {
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);
1778 $territory = strtoupper($territory);
1779 if (array_key_exists($territory, self::$_territoryData)) {
1780 return self::$_territoryData[$territory];
1795 $list = self::$_localeData;
1796 unset($list[
'root']);
1797 unset($list[
'auto']);
1798 unset($list[
'browser']);
1799 unset($list[
'environment']);
1810 #require_once 'Zend/Locale/Data.php'; 1822 #require_once 'Zend/Locale/Data.php'; 1833 #require_once 'Zend/Locale/Data.php'; 1844 #require_once 'Zend/Locale/Data.php'; 1856 #require_once 'Zend/Locale/Data.php'; 1868 #require_once 'Zend/Locale/Data.php'; 1880 private static function _prepareLocale($locale, $strict =
false)
1883 $locale = $locale->toString();
1886 if (is_array($locale)) {
1890 if (empty(self::$_auto) ===
true) {
1893 self::$_breakChain =
true;
1898 if ($locale ===
'browser') {
1902 if ($locale ===
'environment') {
1906 if ($locale ===
'default') {
1910 if (($locale ===
'auto') or ($locale ===
null)) {
1914 if (is_array($locale) ===
true) {
1915 $locale = key($locale);
1920 if ($locale ===
null) {
1921 #require_once 'Zend/Locale/Exception.php'; 1925 if (strpos($locale,
'-') !==
false) {
1926 $locale = strtr($locale,
'-',
'_');
1929 $parts = explode(
'_', $locale);
1930 if (!isset(self::$_localeData[$parts[0]])) {
1931 if ((count($parts) == 1) && array_key_exists($parts[0], self::$_territoryData)) {
1932 return self::$_territoryData[$parts[0]];
1938 foreach($parts as $key =>
$value) {
1940 unset($parts[$key]);
1944 $locale = implode(
'_', $parts);
1945 return (
string) $locale;
1961 self::$_breakChain =
true;
1966 self::$_breakChain =
true;
1971 self::$_breakChain =
true;
1988 $locale = $locale->toString();
1991 return isset(self::$_localeAliases[$locale]);
2003 $locale = $locale->toString();
2006 if (isset(self::$_localeAliases[$locale]) ===
true) {
2007 return self::$_localeAliases[$locale];
2010 return (
string) $locale;
static getCountryTranslationList($locale=null)
static getTranslation($value=null, $path=null, $locale=null)
static getList($locale, $path, $value=false)
static getLanguageTranslationList($locale=null)
__construct($locale=null)
static getContent($locale, $path, $value=false)
static getTerritoryTranslationList($locale=null)
static $languageTranslation
static $compatibilityMode
static getTerritoryTranslation($value, $locale=null)
static getOrder($order=null)
static setDefault($locale, $quality=1)
static isRegistered($index)
equals(Zend_Locale $object)
static getLanguageTranslation($value, $locale=null)
static isLocale($locale, $strict=false, $compatible=true)
static setCache(Zend_Cache_Core $cache)
static disableCache($flag)
static getCountryTranslation($value, $locale=null)
static getTranslationList($path=null, $locale=null, $value=null)
static findLocale($locale=null)
static getQuestion($locale=null)
static disableCache($flag)
static setCache(Zend_Cache_Core $cache)
static clearCache($tag=null)
static getLocaleToTerritory($territory)
static $regionTranslation
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
static getScriptTranslation($value, $locale=null)
static getScriptTranslationList($locale=null)