Change language without login

Permalink
Hi,

I try to find a way to change the site language when the user is not logged, because i use the core commerce addon and i will to have the right translation. I'm working with 5.6+.

Here my solution that doesn't work, core-commerce are not translated during the session. I've created a small package with in the controller :

function on_start() {
          if (!$_SESSION['uID'] || $_GET['lang']) {
               if($_GET['lang']) {
                    $lang = $_GET['lang'];
               } else { 
                  Loader::library('3rdparty/Zend/Locale');
                    Loader::library('3rdparty/Zend/Locale/Data');
                    $languages = Localization::getAvailableInterfaceLanguages();
                    $lang = $languages[0];
               }
               $_SESSION['uDefaultLanguage'] = $lang;
                define('LOCALE', $lang);
                setlocale(LC_ALL,$lang);
          }
     }


Anyone can help me ?

sebastienj