Search code examples
phpsymfonylocale

symfony Locale being set to en_US


I have installed three locale settings bundles:

My config.yml looks like this:

jms_i18n_routing:
    default_locale: en
    locales: [en, fr, es]
    strategy: prefix

lunetics_locale:
    strict_mode: false
    allowed_locales: [en, fr, es]
    guessing_order:
        - query
        - router
        - session
        - browser
        - cookie

be_simple_i18n_routing: ~

Everything works to my liking, except that I found an error in the log:

[2015-08-02 01:16:48] request.CRITICAL: Exception thrown when handling an exception (Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("I18nRoute "site_homepage" (en_US) does not exist.") in "TwigBundle:Exception:error.html.twig" at line 77. at /app/cache/prod/classes.php line 4528) {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"I18nRoute \"site_homepage\" (en_US) does not exist.\") in \"TwigBundle:Exception:error.html.twig\" at line 77. at /app/cache/prod/classes.php:4528, Symfony\\Component\\Routing\\Exception\\RouteNotFoundException(code: 0): I18nRoute \"site_homepage\" (en_US) does not exist. at /app/cache/prod/classes.php:14728)"} []

In the stack I find: [2015-08-02 01:16:49] app.INFO: Setting [ en_US ] as locale for the (Sub-)Request [] [] However, I don't understand how it's possible to have the locale set as "en_US".

I suppose it comes from the guessing of LuneticsLocaleBundle but someone with "en_US" should match "en", not "en_US".

My main issue is that I have no idea how track this. When I connect to the homepage with my own settings, which have "fr_FR" first, there is absolutely no problem.

Does anyone have ideas of test I could run to fix this?


Solution

  • There was a conflict between Lunetics Bundle and JMSi18n since I updated to symfony2.7.

    Apparently it was a problem when dealing with sub-requests, Lunetics was overtaken by the JMS bundle.

    So I now use only JMS for locale detection. It is much less clean than Lunetics but it works.