BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 38 forks source link

[BUG] Locales var not always available #122

Open HerveEmagma opened 7 years ago

HerveEmagma commented 7 years ago

Hello everybody,

When I try to access global 'locales' var with a wrong locale in url (example : www.mywebsite.com/sdlkgdsg/page/1 instead of a valid www.mywebsite.com/en/page/1), i get a

Twig_Error_Runtime in Template.php line 487: Variable "locales" does not exist in ...

For example, It happens when I use localeswitcher twig function.

So, after some tests, I found it can be resolved by setting a high priority on before in translateExtension registerServices :


    protected function registerServices(Application $app)
    {
        $this->registerTranslateServices($app);
        $this->registerOverrides($app);

        $app->before([$this, 'before'], 99);
    }

I don't know if it's the best way to fix it. Anybody have a better suggestion ?

Another question : is it possible to define a default fallback route when locale in url is not valid ?

Thx !

RicardoEPRodrigues commented 5 years ago

Hello.

I found this bug as well, specially on the 404 page. This does define the locales, but it doesn't set which is active.