Sam
Sam

Reputation: 779

Symfony 2.3 : InvalidArgumentException: Only the locale "en" is supported

My translated website version of symfony 2.2 was right till I have upgraded to v.2.3.2.

I have all my translated files in yml format. And seems to be good.

I have seen that in the new version, Symfony use its own Intl, right? But why it doesn't want to translate my pages?

1/1 InvalidArgumentException: Only the locale "en" is supported.

for information i have these values into my php info:

intl

Internationalization support    enabled
version 1.1.0
ICU version 4.8.1.1
ICU Data version    4.8.1

Directive   Local Value Master Value
intl.default_locale no value    no value
intl.error_level    0   0

EDIT:

It seems that the problem comes from the CountryType. If I force the locale to english it works.

Upvotes: 2

Views: 2401

Answers (3)

T-Rex
T-Rex

Reputation: 35

I debug the error and it brings me finally to

vendor/symfony/symfony/src/Symfony/Component/Translation/Translator.php

In the variable $locale on line 420 stands "de " (in my case). The empty space is the problem. If you put $locale = trim($locale); before the regular expression it works.

Upvotes: 1

Ousmane
Ousmane

Reputation: 2921

I solved this problem by installing the symfony intl component.

Try to add this line to your composer.json :

"symfony/intl": "2.6.*@dev"

Upvotes: 1

jody_lognoul
jody_lognoul

Reputation: 817

It seems to fail for the dates formatage. It uses the IntlDateFormatter which is only compatible with "en" date format.

Can you disable the translation for the dates from a page and see if it's works ?

Otherwise comment this part of the source code of Symfony :

if ('en' != $locale) {
            throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
        }

Upvotes: 0

Related Questions