Welcome Guest, Not a member yet? Register   Sign In
multilanguage database struct
#4

[eluser]siubie[/eluser]
hai isern i try your solution but when i use print $this->idoma there is notthing appear ?
where do i wrong

i use URI Language Identifier from wiki this is my file

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Language extends CI_Language
{
    function MY_Language() {

        global $RTR;

        $index_page    = $RTR->config->item('index_page');
        $lang_uri_abbr = $RTR->config->item('lang_uri_abbr');

        /* get the lang_abbr from uri segments */
        $lang_abbr = current($RTR->uri->segments);

        /* check for invalid abbreviation */
        if( ! isset($lang_uri_abbr[$lang_abbr])) {

            $deft_abbr = $RTR->config->item('language_abbr');

            /* check for abbreviation to be ignored */
            if ($deft_abbr != $RTR->config->item('lang_ignore')) {

                /* check and set the default uri identifier */
                $index_page .= empty($index_page) ? $deft_abbr : "/$deft_abbr";

                /* redirect after inserting language id */
                header('Location: '.$RTR->config->item('base_url').$index_page.$RTR->uri->uri_string);
            }

            /* get the language name */
            $user_lang = $lang_uri_abbr[$deft_abbr];

        } else {

            /* get the language name */
            $user_lang = $lang_uri_abbr[$lang_abbr];

            /* reset config language to match the user language */
            $RTR->config->set_item('language', $user_lang);
            $RTR->config->set_item('language_abbr', $lang_abbr);

            /* check for abbreviation to be ignored */
            if ($lang_abbr != $RTR->config->item('lang_ignore')) {

                /* check and set the user uri identifier */
                   $index_page .= empty($index_page) ? $lang_abbr : "/$lang_abbr";

                /* reset uri segments and uri string */
                $RTR->uri->_reindex_segments(array_shift($RTR->uri->segments));
                $RTR->uri->uri_string = str_replace("/$lang_abbr/", '/', $RTR->uri->uri_string);
            }
        }

        /* reset the index_page value */
        $RTR->config->set_item('index_page', $index_page);
        log_message('debug', "MY_Language Class Initialized");
    }
}

/* translate helper */
  function t($line) {
      global $CI;
      return ($t = $CI->lang->line($line)) ? $t : $line;
  }

function getLanguage()
{
    $CI =& get_instance();

    return $CI->session->userdata('language');
}

function getLanguageId()
{
    $CI =& get_instance();

    return $CI->session->userdata('language_id');
}

and my baseController.php

Code:
<?php

class BaseController extends Controller {

    public $idioma = NULL;

    public function BaseController()
    {
        parent::Controller();

        $language = $this->config->item('language_abbr');
        $this->session->set_userdata('language', $language);

        $query = $this->_getLanguageId($language);

        if($query->num_rows() > 0)
        {
            $row = $query->row();

            $languageId = $row->idbahasa;

            $this->session->set_userdata('language_id',$languageId);
        }

        $this->idioma = getLanguageId();
        log_message('debug', "BaseController Class Initialized");
    }

    private function _getLanguageId($codigo)
    {
        return $this->db->get_where('bahasa', array('kode' => $codigo));
    }

}


Messages In This Thread
multilanguage database struct - by El Forum - 02-17-2010, 03:09 AM
multilanguage database struct - by El Forum - 02-17-2010, 04:36 AM
multilanguage database struct - by El Forum - 02-17-2010, 05:29 AM
multilanguage database struct - by El Forum - 03-29-2010, 07:26 AM
multilanguage database struct - by El Forum - 03-29-2010, 07:28 AM
multilanguage database struct - by El Forum - 03-29-2010, 07:36 AM
multilanguage database struct - by El Forum - 03-29-2010, 07:47 AM
multilanguage database struct - by El Forum - 03-29-2010, 07:56 AM
multilanguage database struct - by El Forum - 03-29-2010, 08:04 AM
multilanguage database struct - by El Forum - 03-29-2010, 08:10 AM
multilanguage database struct - by El Forum - 03-29-2010, 08:34 AM
multilanguage database struct - by El Forum - 03-29-2010, 08:43 AM
multilanguage database struct - by El Forum - 04-22-2011, 03:00 AM
multilanguage database struct - by El Forum - 10-20-2012, 04:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB