I changed the option for "Currency amount formatting" to English (United Kingdom).
While trying to setup the exchange rates, the following error was logged:
---
RuntimeException: The currency locale for en_US could not be loaded. in Drupal\currency\LocaleResolver->resolveCurrencyLocale() (line 103 of /.../modules/currency/src/LocaleResolver.php).
---

Comments

Londova created an issue. See original summary.

xano’s picture

Status: Active » Postponed (maintainer needs more info)

Thank you for reporting this problem! Can you please update the issue summary with detailed step-by-step instructions on how to reproduce the problem on a clean Drupal installation using only the absolutely necessary additional modules?

flk’s picture

Version: drupal-8.3.4
PHP 7
Apache2
OS: Ubuntu 17.04

----

Installed module, added 2 (GBP and USD) currencies using the 'Import a currency'
then went to
1. /admin/config/regional/currency-exchange
2. admin/config/regional/currency-exchange/fixed (edit fixed rates)

entered the rate as 1.24 and saved and following error showed up: "The website encountered an unexpected error. Please try again later."

Upon looking at the error logs, i see the below and can no longer access the fixed rate edit screen(2):
Uncaught PHP Exception RuntimeException: "The currency locale for en_US could not be loaded." at /var/www/d8/drupal-8.3.4/modules/contrib/currency/src/LocaleResolver.php line 103, referer: http://d8.local/admin/config/regional/currency-exchange

flk’s picture

Status: Postponed (maintainer needs more info) » Active
vaza18’s picture

Check that you have English (US) locale at "/admin/config/regional/currency-formatting/locale"
This may happen if you loose config file and reinstalled the site using config-import.
I had the same issue and it got's resolved when I added English (United States) locale manually.

h3rj4n’s picture

Status: Active » Needs review
StatusFileSize
new633 bytes

I ran into the same problem. I've my site set to Netherlands/Amsterdam. I don't want to install ore use the en_US locale. I think this is the problem:

// 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);
        }

      }

Here the class LocaleResolver tries to access the config file system.data which does not exists. I think it's a typo because system.date does exist ;)

I've added a patch to fix this.

berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Yeah, once more a problem with unit test faking the same bugs as the real code. \Drupal\Tests\currency\Unit\LocaleResolverTest needs to be updated, triggered a test which should fail now.

berdir’s picture

Title: ERROR: RuntimeException: The currency locale for en_US could not be loaded » RuntimeException: The currency locale for en_US could not be loaded
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.71 KB
berdir’s picture

Status: Needs review » Fixed
StatusFileSize
new1.71 KB

Committed.

  • Berdir committed fe6cc48 on 8.x-3.x
    Issue #2807531 by Berdir, h3rj4n: RuntimeException: The currency locale...
berdir’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.