Welcome Guest, Not a member yet? Register   Sign In
Calendar question
#5

[eluser]mick_sp[/eluser]
Hi Derek

So how do you change the language of the whole site? I followed the instruction in the documentation on changing the language and it works fine for variables i made myself, but the calendar doesn't change along with it. Here's my code so far:

In my controller I use properties to keep track of the choosen language:
Code:
class Main extends Controller {
  // fixme: this should be in config
  var $languages = array('0'=>'nederlands', // dutch
                         '1'=>'deutsch',    // german
                         '2'=>'english');
  var $currentLang;
Then in the constructor, I initialize and save the current language in the session for refference on other places:
Code:
function Main(){
    parent::Controller();
    $languages = $this->getLanguages();
    $this->setCurrentLang(0);
    $lang = $this->session->userdata('lang');
    if((isset($lang))&&($lang > 0)) $this->setCurrentLang($lang);
  }
Starting the index i look up the choosen language, and set the variables accordingly:
Code:
function index(){
    $languages = $this->getLanguages();
    // Get the right translation
    $this->lang->load('_site', $languages[$this->getCurentLang()]);    // site specific strings
    $this->lang->load('calendar', $languages[$this->getCurentLang()]); // calendar translation
    // get the translated strings
    $data["titel"] = $this->lang->line('titel');
-- SNIP --
    // for setting the right flag in the view    
    $data["lang"] = $this->currentLang;
    $data["languages"] = $languages;
    $this->load->view('main/homepage', $data);
  }
The calendar class uses $this->CI->lang->load($lang)in its constructor to get the right strings (before loading the prefs), but in there is only the default language, english. So i need to change the language it's going to load before loading the calendar-class. Can you help me on this?

Greetings
Michaƫl


Messages In This Thread
Calendar question - by El Forum - 08-23-2007, 06:54 AM
Calendar question - by El Forum - 08-23-2007, 07:16 AM
Calendar question - by El Forum - 08-23-2007, 07:18 AM
Calendar question - by El Forum - 08-23-2007, 09:13 AM
Calendar question - by El Forum - 09-20-2007, 02:04 AM
Calendar question - by El Forum - 09-20-2007, 05:21 AM
Calendar question - by El Forum - 09-20-2007, 06:39 AM
Calendar question - by El Forum - 09-20-2007, 08:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB