2

Receiving the following error message when trying to run my project.

Fatal error: Uncaught exception 'Doctrine\ODM\PHPCR\Translation\MissingTranslationException' with message 'The locale 'en' is not present in the list of available locales' in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133

Doctrine\ODM\PHPCR\Translation\MissingTranslationException: The locale 'en' is not present in the list of available locales in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133

And the following stack trace:

#   Time    Memory  Function   Location
1   0.0040  240752  {main}( )   ../app.php:0
2   0.0299  643576  Symfony\Component\HttpKernel\HttpCache\HttpCache->handle( ) ../app.php:20
3   0.0309  657488  Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup( ) ../HttpCache.php:193
4   0.0316  659008  Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch( )  ../HttpCache.php:329
5   0.0317  665184  Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache->forward( )  ../HttpCache.php:429
6   0.4876  9740256 Symfony\Component\HttpKernel\HttpCache\HttpCache->forward( )    ../HttpCache.php:60
7   0.4877  9742120 Symfony\Component\HttpKernel\Kernel->handle( )  ../HttpCache.php:466
8   0.4957  9838264 Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle( )    ../Kernel.php:187

That is all what I am getting as error report. What could be going wrong?

edit: Here is a part my config.yml;

framework:
  #esi:             ~
  translator:      { fallback: en }
  secret:          %secret%
  router:          { resource: "%kernel.root_dir%/config/routing.yml" }
  form:            true
  csrf_protection: true
  templating:      { engines: ['twig'] } #assets_version: SomeVersionScheme
  default_locale:  %locale%
  session:         ~

edit 2: After configuring config.yml;

Warning: filemtime(): stat failed for /var/www/sources/piccolo-standard/app/config/config.yml in /var/www/sources/piccolo-standard/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php on line 68

Fatal error: Uncaught exception 'Doctrine\ODM\PHPCR\Translation\MissingTranslationException' with message 'The locale 'en' is not present in the list of available locales' in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133

Doctrine\ODM\PHPCR\Translation\MissingTranslationException: The locale 'en' is not present in the list of available locales in /var/www/sources/piccolo-standard/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php on line 133

Edit 3: Solution The problem was a combining of two issues. The first one was the config.yml. Make sure that the 'doctrine_phpcr.odm.locales' section is set as followed (or something a like, considering what languages you support):

locales:
   en: [de, fr]
   de: [en, fr]
   fr: [en, de]

And the second problem was the absence of database connection configured in 'parameters.yml'. Without connection to my database, the server most likely tried to load an English object (perhaps a DateTime) and failed to load.

Lars
  • 340
  • 4
  • 19

1 Answers1

0

This is may be stupid, but have you tried to quote your language value ?

like this :

  Translator : { fallback  : 'en' } 

in all of our symfony project we use the locale variable instead of an hard value

  Translator : { fallback : "%locale%" }

according to this source code : https://github.com/doctrine/phpcr-odm/blob/master/lib/Doctrine/ODM/PHPCR/Translation/LocaleChooser/LocaleChooser.php

the language definition should be quoted ( line 37 )

   /**
    * locale fallback list indexed by source locale
    *
    * example:
    * array(
    * 'en' => array('en', 'de', 'fr'),
    * 'fr' => array('fr', 'de', 'en'),
    * 'de' => array('de', 'fr', 'en'),
    * )
    */
   protected $localePreference;

hope that will help you

EDIT : Did you correctly setup you php-cr parameters ?

here is an example from symfony.com

 doctrine_phpcr:
    odm:
    # ...
       locales:
           en: [de, fr]
           de: [en, fr]
           fr: [en, de]
       locale_fallback: hardcoded

http://symfony.com/doc/current/cmf/bundles/phpcr_odm/multilang.html

Charles-Antoine Fournel
  • 1,713
  • 1
  • 25
  • 37
  • Thanks for your response, but quoting did not help with our issue. The part in LocaleChooser.php is indeed commented as stated above. – Lars Sep 08 '14 at 09:34
  • Placed the same example in my project. Now I still receive the same error that 'en' is not present in the available list of locale. But I also receive the error, wich I placed in my first post. – Lars Sep 08 '14 at 09:52
  • clearing your cache for the stat error should resolve it – Charles-Antoine Fournel Sep 08 '14 at 09:56
  • When trying to clear cache, terminal tells me the following: 'Unrecognized options "locale_fallback" under "doctrine_phpcr.odm"' – Lars Sep 08 '14 at 09:59
  • may be this parameter is outdated , remove it the clear cache again – Charles-Antoine Fournel Sep 08 '14 at 10:02
  • Thanks! It works at my end, but the weird thing is; it doesn't on my colleague his computer. This is one crazy error. – Lars Sep 08 '14 at 13:10
  • it's usually a cache issue, everytime you edit / modify a .yml , try to clear you cache :) . if it works for you , you can mark the aswer as accepted to close it – Charles-Antoine Fournel Sep 08 '14 at 13:14