7UP9?&7U:;n7UPP:B6Up:6U`p:6U` <s7U<+6U`<Qs6U<6U@<*c6U<h6U<>D6Up=>#%*oAoAaVU46Up=6UpPA6U``A 7UPi6UP`7U`@+D6U>46U=6UPA6U`A7UD6U>oA`}wAheAxtaVU46Up=6UpPA6U``A 7UPi6UP`7U`@+D6U>46U=6UPA6U`A7UD6U>oA0*0~wAJ))aVU46U`=46U`P=7UP 6UP p6U`<7U`Pu6U`A6UpA 7Up 6Up>D6U>>pA*tAtATKXY~AaVU0O/xAd/46U``=6UPPA 7UPi6UP`7U`@+D6U>46U=6UPA6U`A7UD6U>oAF0}wA/,aVU'0g/6U`HI6UPII6U@JI6U0KI6U LI6UNqm6UND]6UN<7UPNu7UND6UO>$--@$$t/t/I0/aVU 7UP?6UaV``[%6U`Pp[6UpPs7U+6U0R16UHR6UPQI6UQh6U>(6UP>D6Up>@xA`JxAЉoAaVU0~wAA 7UP ?6U@p R6U`` [56U`p Z6UP s7U@ +D6U >6U|/HR6U0RA6UQ6UPQh6U>D6Up>hQ/|/"08N*aVUSystem = Locale::NUMBERING_SYSTEM_LATIN, $currencyDisplayType = PriceSpecification::CURRENCY_DISPLAY_SYMBOL, $groupingUsed = true, $maxFractionDigits = self::MAX_FRACTION_DIGITS ) { $this->cldrLocaleRepository = $cldrLocaleRepository; $this->currencyRepository = $currencyRepository; $this->roundingMode = $roundingMode; $this->numberingSystem = $numberingSystem; $this->currencyDisplayType = $currencyDisplayType; $this->numberGroupingUsed = $groupingUsed; $this->maxFractionDigits = $maxFractionDigits; $this->specificationFactory = new SpecificationFactory(); } /** * {@inheritdoc} */ public function getLocale($localeCode) { if (!isset($this->locales[$localeCode])) { $this->locales[$localeCode] = new Locale( $localeCode, $this->getNumberSpecification($localeCode), $this->getPriceSpecifications($localeCode), new NumberFormatter($this->roundingMode, $this->numberingSystem) ); } return $this->locales[$localeCode]; } /** * Get the Number specification for a given locale. * * @param string $localeCode * The locale code (simplified IETF tag syntax) * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) * eg: fr-FR, en-US * * @return NumberSpecification * A Number specification * * @throws LocalizationException */ protected function getNumberSpecification($localeCode) { $cldrLocale = $this->cldrLocaleRepository->getLocale($localeCode); if (null === $cldrLocale) { throw new LocalizationException('CLDR locale not found for locale code "' . $localeCode . '"'); } return $this->specificationFactory->buildNumberSpecification( $cldrLocale, $this->maxFractionDigits, $this->numberGroupingUsed ); } /** * Get all the Price specifications for a given locale. * Each installed currency has its own Price specification. * * @param string $localeCode * The locale code (simplified IETF tag syntax) * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) * eg: fr-FR, en-US * * @return PriceSpecificationMap * All installed currencies' Price specifications * * @throws LocalizationException */ protected function getPriceSpecifications($localeCode) { $cldrLocale = $this->cldrLocaleRepository->getLocale($localeCode); if (null === $cldrLocale) { throw new LocalizationException('CLDR locale not found for locale code "' . $localeCode . '"'); } $currencies = $this->currencyRepository->getAllInstalledCurrencies($localeCode); $priceSpecifications = new PriceSpecificationMap(); foreach ($currencies as $currency) { // Build the spec $thisPriceSpecification = (new SpecificationFactory())->buildPriceSpecification( $localeCode, $cldrLocale, $currency, $this->numberGroupingUsed, $this->currencyDisplayType, (int) $currency->getDecimalPrecision() ); // Add the spec to the collection $priceSpecifications->add( $thisPriceSpecification->getCurrencyCode(), $thisPriceSpecification ); } return $priceSpecifications; } /** * @return bool */ public function isNumberGroupingUsed() { return $this->numberGroupingUsed; } /** * @return string */ public function getCurrencyDisplayType() { return $this->currencyDisplayType; } }