![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/magento/framework/Locale/Bundle/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Locale\Bundle; class DataBundle { /** * @var string */ protected $path = 'ICUDATA'; /** * @var \ResourceBundle[][] */ protected static $bundles = []; /** * Get resource bundle for the locale * * @param string $locale * @return \ResourceBundle */ public function get($locale) { $locale = $this->cleanLocale($locale); $class = get_class($this); if (!isset(static::$bundles[$class][$locale])) { $bundle = $this->createResourceBundle($locale, $this->path); if (!$bundle && $this->path != 'ICUDATA') { $bundle = $this->createResourceBundle($locale, 'ICUDATA'); } static::$bundles[$class][$locale] = $bundle; } return static::$bundles[$class][$locale]; } /** * @param string $locale * @param string $path * @return null|\ResourceBundle */ protected function createResourceBundle($locale, $path) { try { $bundle = new \ResourceBundle($locale, $path); } catch (\Exception $e) { // HHVM compatibility: constructor throws on invalid resource $bundle = null; } return $bundle; } /** * Clean locale leaving only language and script * * @param string $locale * @return string */ protected function cleanLocale($locale) { $localeParts = \Locale::parseLocale($locale); $cleanLocaleParts = []; if (isset($localeParts['language'])) { $cleanLocaleParts['language'] = $localeParts['language']; } if (isset($localeParts['script'])) { $cleanLocaleParts['script'] = $localeParts['script']; } return \Locale::composeLocale($cleanLocaleParts); } }