/** * {@inheritdoc} */ public function resolveCurrencyLocale($language_type = LanguageInterface::TYPE_CONTENT) { if (empty($this->currencyLocales[$language_type])) { $currency_locale = NULL; $language_code = $this->languageManager->getCurrentLanguage($language_type)->getId(); // Try this request's country code. $country_code = $this->eventDispatcher->resolveCountryCode(); if ($country_code) { $currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code); } // Try the site's default country code. if (!$currency_locale) { $country_code = $this->configFactory->get('system.data')->get('country.default'); if ($country_code) { $currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code); } } // Try the Currency default. if (!$currency_locale) { $currency_locale = $this->currencyLocaleStorage->load($this::DEFAULT_LOCALE); } if ($currency_locale) { $this->currencyLocales[$language_type] = $currency_locale; } else { throw new \RuntimeException(sprintf('The currency locale for %s could not be loaded.', $this::DEFAULT_LOCALE)); } } return $this->currencyLocales[$language_type]; }