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

Hi, just wondering if it's possible to specify other names for days (e.g., another language) in the calendar library.

Something like

$prefs = array(
    'day_names' = array("man", "tirs", "ons", "tors", "fre", "lør", "søn")

if you catch my drift.


You can edit the language file for calendar:

$lang['cal_su']        = "Sø";
$lang['cal_mo']         = "Ma";
$lang['cal_tu']         = "Ti";
$lang['cal_we']         = "On";
$lang['cal_th']         = "To";
$lang['cal_fr']         = "Fr";
$lang['cal_sa']         = "Lø";
$lang['cal_sun']         = "Søn";
$lang['cal_mon']         = "Man";
$lang['cal_tue']         = "Tir";
$lang['cal_wed']         = "Ons";
$lang['cal_thu']         = "Tor";
$lang['cal_fri']         = "Fre";
$lang['cal_sat']         = "Lør";
$lang['cal_sunday']        = "Søndag";
$lang['cal_monday']        = "Mandag";
$lang['cal_tuesday']    = "Tirsdag";
$lang['cal_wednesday']    = "Onsdag";
$lang['cal_thursday']    = "Torsdag";
$lang['cal_friday']        = "Fredag";
$lang['cal_saturday']    = "Lørdag";
$lang['cal_jan']         = "Jan";
$lang['cal_feb']         = "Feb";
$lang['cal_mar']         = "Mar";
$lang['cal_apr']         = "Apr";
$lang['cal_may']         = "Mai";
$lang['cal_jun']         = "Jun";
$lang['cal_jul']         = "Jul";
$lang['cal_aug']         = "Aug";
$lang['cal_sep']         = "Sep";
$lang['cal_oct']         = "Okt";
$lang['cal_nov']         = "Nov";
$lang['cal_dec']         = "Des";
$lang['cal_january']     = "Januar";
$lang['cal_february']     = "Februar";
$lang['cal_march']         = "Mars";
$lang['cal_april']        = "April";
$lang['cal_mayl']         = "Mai";
$lang['cal_june']         = "Juni";
$lang['cal_july']         = "Juli";
$lang['cal_august']        = "August";
$lang['cal_september']    = "September";
$lang['cal_october']     = "Oktober";
$lang['cal_november']    = "November";
$lang['cal_december']     = "Desember";

Thanks! I should've looked at that. But thank you!

[eluser]Derek Allard[/eluser]
Or better yet, rather then editing the English library, get your self a copy of the language you want, and change the language of the entire application.

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:
class Main extends Controller {
  // fixme: this should be in config
  var $languages = array('0'=>'nederlands', // dutch
                         '1'=>'deutsch',    // german
  var $currentLang;
Then in the constructor, I initialize and save the current language in the session for refference on other places:
function Main(){
    $languages = $this->getLanguages();
    $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:
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?


[eluser]Derek Allard[/eluser]
What I mean is, in the system/languages folder, create a folder named "french" (or whatever). Now get a copy of the french CI library (you'll need to search around these forums or grab it off my site).

Now in config.php, change $config['language'] to "french". The calendar should adapt. I'm not sure about dynamically changing languages, you'll need to intercept the normal CI flow.

Hi Derek

Thanks, i now use this in my "setlanguage function:
function switchlang($lang=0){
    $languages = $this->getLanguages();
    // check whether this is a valid language
      $this->session->set_userdata("lang", $lang);
    // change global language
    $this->config->set_item('language', $languages[$lang]); // thanks, Derek!
    // continue to index
    /** @todo keep track of current page */
This works great!

[eluser]Derek Allard[/eluser]
Horray! Thanks for sharing.

Theme © iAndrew 2016 - Forum software by © MyBB