Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
85 stars 28 forks source link

Can't force certain locale #38

Closed kovinet closed 3 years ago

kovinet commented 3 years ago

I am using this bundle but I have a problem that it is translating entity to locale set in Request, which is not the desired behaviour.

For example I don't have translations for en locale, I only have them for 'sl', but with request with header accept-language: en,sl empty translations are returned even though default locale is set to 'sl'.

Is there a way to configure the bundle to only use predefined pool of locales (for example: sl, de), so it will ignore request locale but always use fixed one?

paullla commented 3 years ago

Hi @kovinet, bundle first checks if there is a locale sent in the request and uses that one. If locale is not sent in the request, it uses default locale set in config.

If you would like to have a different flow, you can override loadCurrentLocale method in Translator: https://github.com/Locastic/ApiPlatformTranslationBundle/blob/master/src/Translation/Translator.php#L61