Parses a locale string into it's respective framgments

@param string $sLocale The string to parse

@return string[]
185987
public static function parseLocaleString(?string $sLocale): array
    {
        return [
            \Locale::getPrimaryLanguage($sLocale),
            \Locale::getRegion($sLocale),
            \Locale::getScript($sLocale),
        ];
    }
797950
public function getLocalization($locale)
    {
        $dataCollection = $this->getLocalizations();
        $data = $dataCollection->get($locale);

        return $data;
    }
1232357
private function getLocaleCode($locale)
    {
        $locales = explode('_', strtolower($locale));
        $locale = array_pop($locales);

        if ('en' === $locale) {
            $locale = 'gb';
        }

        return $locale;
    }
692208
public function getLocaleDependencies($locale) {
		$dependencies = array();
		if (isset($this->localeDependencies[$locale])) {
			$dependencies = $this->localeDependencies[$locale];

				// Search for dependencies recursively
			$localeDependencies = $dependencies;
			foreach ($localeDependencies as $dependency) {
				if (isset($this->localeDependencies[$dependency])) {
					$dependencies = array_merge($dependencies, $this->getLocaleDependencies($dependency));
				}
			}
		}
		return $dependencies;
	}
699340
public static Locale toLocale(String strLocale, Locale defaultValue) {
	return LocaleFactory.getLocale(strLocale, defaultValue);
    }
412794
private function parse($locale)
    {
        $parts = explode('_', $locale);

        $localization = new Localization();
        $localization->setLanguage($parts[0]);
        if (count($parts) > 1) {
            $localization->setCountry($parts[1]);
        }

        return $localization;
    }
1176544
private static int[] findCodeFromLocale(ULocale locale) {
        int[] result = getCodesFromLocale(locale);
        if(result != null) {
            return result;
        }
        ULocale likely = ULocale.addLikelySubtags(locale);
        return getCodesFromLocale(likely);
    }
825440
public static function getListOfTimezones(string $locale = '') : array
    {
        date_default_timezone_set('UTC');
        $identifiers = \DateTimeZone::listIdentifiers();
        foreach($identifiers as $i) {
            // create date time zone from identifier
            $dtz = new \DateTimeZone($i);
            // create timezone from identifier
            $tz = \IntlTimeZone::createTimeZone($i);
            // if IntlTimeZone is unaware of timezone ID, use identifier as name, else use localized name
            if ($tz->getID() === 'Etc/Unknown' or $i === 'UTC') $name = $i;
            else $name =  $tz->getDisplayName(false, 3, $locale);
            // time offset
            $offset = $dtz->getOffset(new \DateTime());
            $sign   = ($offset < 0) ? '-' : '+';

            $tzs[] = [
                'code'   => $i,
                'name'   => $name . '(UTC' . $sign . date('H:i', abs($offset)) . ') ',
                'offset' => $offset,
            ];
        }
        ArrayHelper::multisort($tzs, ['offset', 'name']);
        // sort by offset
        //    usort($tzs, function($a, $b){
        //        if ($a['offset'] > $b['offset']) {
        //            return 1;
        //        }
        //        elseif ($a['offset'] < $b['offset']) {
        //            return -1;
        //        }
        //        elseif ($a['name'] > $b['name']) {
        //            return 1;
        //        }
        //        elseif ($a['name'] < $b['name']) {
        //            return -1;
        //        }
        //        return 0;
        //    });
        return array_column($tzs, 'name', 'code');
    }
753763
public static function getByLocale($locale)
    {
        if (!$locale) {
            return null;
        }

        if ($locale instanceof Locale) {
            return $locale;
        }

        if (!static::$locales_by_title) {
            static::$locales_by_title = [];
            foreach (Locale::getCached() as $localeObj) {
                static::$locales_by_title[$localeObj->Locale] = $localeObj;
            }
        }

        // Get filtered locale
        return isset(static::$locales_by_title[$locale]) ? static::$locales_by_title[$locale] : null;
    }
639980
public function getConcreteLocales($document)
    {
        $locales = $this->getLocales($document);

        if ($document instanceof ShadowLocaleBehavior) {
            $locales = array_diff($locales, array_keys($this->getShadowLocales($document)));
        }

        return array_values($locales);
    }
1027200
private function getAdditionalLinks($locale)
    {
        $return = [];
        $additional_links = $this->container->getParameter('networking_init_cms.xml_sitemap.additional_links');
        foreach ($additional_links as $links) {
            if ($links['locale'] == $locale) {
                return $links['links'];
            }
        }

        return $return;
    }
891232
private static Locale parseLocale(final String str) {
        if (isISO639LanguageCode(str)) {
            return new Locale(str);
        }

        final String[] segments = str.split("_", -1);
        final String language = segments[0];
        if (segments.length == 2) {
            final String country = segments[1];
            if (isISO639LanguageCode(language) && isISO3166CountryCode(country) ||
                    isNumericAreaCode(country)) {
                return new Locale(language, country);
            }
        } else if (segments.length == 3) {
            final String country = segments[1];
            final String variant = segments[2];
            if (isISO639LanguageCode(language) &&
                    (country.length() == 0 || isISO3166CountryCode(country) || isNumericAreaCode(country)) &&
                    variant.length() > 0) {
                return new Locale(language, country, variant);
            }
        }
        throw new IllegalArgumentException("Invalid locale format: " + str);
    }
940480
public function getLangByLocale($locale)
    {
        // Event parameters prepare
        $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());

        // Sending service start event
        $arrayParameters = $this->sendEvent('melisengine_service_get_lang_by_local_start', $arrayParameters);

        // Service implementation start
        $langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $result = $langTable->getEntryByField('lang_cms_locale', $locale)->toArray();
        if(!isset($result[0]['lang_cms_locale'])) return null;
        $result = $result[0];
        // Service implementation end

        // Adding results to parameters for events treatment if needed
        $arrayParameters['results'] = $result;
        // Sending service end event
        $arrayParameters = $this->sendEvent('melisengine_service_get_lang_by_local_end', $arrayParameters);

        return $arrayParameters['results'];
    }
439066
private function convertSingleEntryToDefault(array $locales): array
    {
        foreach ($locales as $group => $segments) {
            // If single locale is passed, it's considered the default for this group
            if (!is_array($segments)) {
                $locales[$group] = $segments = ['/' => $segments];
            }
        }

        return $locales;
    }
17369
public static Locale parseLocale(String localeString) {
    if (localeString == null) {
      return Locale.US;
    }
    String[] groups = localeString.split("[-_]");
    switch (groups.length) {
      case 1:
        return new Locale(groups[0]);
      case 2:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]));
      case 3:
        return new Locale(groups[0], Ascii.toUpperCase(groups[1]), groups[2]);
      default:
        throw new IllegalArgumentException("Malformed localeString: " + localeString);
    }
  }
299328
public static function all($locale = null)
    {
        return static::keys()->mapWithKeys(function ($key) use ($locale) {
            return [$key => trans("blog::posts.statuses.{$key}", [], $locale)];
        });
    }
44369
public static function getDisplayCurrencies($locale)
    {
        if (null === self::$currenciesNames) {
            self::prepareCurrencies($locale);
        }

        return self::$currenciesNames;
    }