rainlab/translate-plugin

Get translated model by active language not default language

amkrucena opened this issue · 1 comments

Hello,
I have upgraded to OctoberCms v3 and the newest translate version and now I have a little problem. In older versions if I change the page language, the Model was returned in active language, but now it always returns the default language and I can get active language only with lang() or translateContext(), but it works only if get I get to model with first(). For example, if I get list (with get()), I need to loop through to translate. My problem is that in front page uses vuejs and ->lang() option isn't available so I need to translate everything in the controller. And translateContext() works on one specific case with first() . If I get the model with get() or add relations with ->with() they aren't translated. Is there a way to return data in correct language?

Hi @amkrucena

It sounds like the site definition is not being applied. If you are using a PHP route, for use in Vue.js, make sure that route implements the System\Middleware\ActiveSite middleware class. This will ensure the site definition (and locale) is applied to the current request.

I hope this helps!