Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
84 stars 27 forks source link

No locale has been set and current locale is undefined. #18

Closed jean-francine closed 4 years ago

jean-francine commented 4 years ago

Hello,

I’m trying to use LocasticApiTranslationBundle with doctrine but I’m unable to make it work.

it tells me that there is no locale defined but I don't know where to declare the locale ?

Can you help me and tell me what I’m doing wrong please ?

In attachment, the stacktrace,

the source entity (ReferenceMateriel) and the translation entity (ReferenceMaterielTranslation) I use.

Thank you in advance for your help.

Best regards

ReferenceMateriel.txt ReferenceMaterielTranslation.txt stacktrace.txt

jean-francine commented 4 years ago

I used ApiPlatformTranslationBundle with symfony 4.3

paullla commented 4 years ago

Hi @jean-francine I think the problem is in ReferenceMateriel constructor. You didn't call parent constructor, so locale isn't set at all. Also, you don't need to initialise translations collection, since it is done in AbstractTranslatable class. This is what constructor should look like if you wish to use it in your class:

   public function __construct() {
        parent::__construct();
        //...
    }

Please let me know if this helps.

jean-francine commented 4 years ago

Thanks you for the quick reply ! Unfortunately that does not solve the problem. I have the following lines which are the defaults setting in the file config/packages/translation.yaml :

framework: default_locale: en translator: default_path: '%kernel.project_dir%/translations' fallbacks:

is this the correct setting ?

paullla commented 4 years ago

@jean-francine can you check if https://github.com/Locastic/ApiPlatformTranslationBundle/pull/19 fixed your problem by pulling the latest version of the bundle?

jean-francine commented 4 years ago

Hi @paullla ! I just updated the bundle and it works like a charm ! Thank you so much !!

paullla commented 4 years ago

Thank you for your feedback :) Closing the issue.