Switch language when user is not logged

Permalink
Hi,

I try to find a way to change the site language (package translation) when the user is not logged. I'm working with 5.6+ and it seems that lot of things have changed.

Here my solution that doesn't work, packages 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
 
TheRealSean replied on at Permalink Reply
TheRealSean
I'm not to sure if this will help you but I did find yesterday that you can get the current page language using the multilingual package.

MultilingualSection::getCurrentSection()->msLanguage;
//there is a function getLanguage()
//but I assume I need to initialise the class before this is loaded?
//as calling it first would not display the language for me.
MultilingualSection::getLanguage();

There is a few more bits that you seem to be able to access from the model section.php,
packages/multilingual/models/section.php

Sorry I don't know if this is exactly what you want? I am still very new to the translation package and struggling to get through it. C5 is not that good when compared to other cms that multiple languages already.
sebastienj replied on at Permalink Reply
sebastienj
Hi,

thanks for reply.
I search a solution like that but without specific addon. I think it's possible to change the session language into C5 but i don't know how..