Hi, I’m using Translate plugin and trying to load translation via json files on theme/lang folder (en.json - es.json). ActiveLocal changes correctly but only shows content in English. This is the code I’m using to switch between locales:
<?php
function onStart()
{
// Get the active locale from the session
$activeLocale = \Session::get('activeLocale');
// Set the active locale if it exists, otherwise use the default locale
$this['activeLocale'] = $activeLocale ?: \RainLab\Translate\Classes\Translator::instance()->getDefaultLocale();
}
function onSwitchLocale()
{
$locale = input('locale');
if ($locale && in_array($locale, ['en', 'es'])) {
\RainLab\Translate\Classes\Translator::instance()->setLocale($locale);
\Session::put('activeLocale', $locale);
}
return response()->json(['success' => true]);
}
Additionally, I calle the translation value as {{ 'welcome_message' | trans }}
which seem to be correct. Also, if I do something like this, it works: {{ activeLocale == 'es' ? 'Hola' : 'Hello' }}
What may I am doing wrong?