Welcome Guest, Not a member yet? Register   Sign In
URI Language Identifier and CI 1.6.1
#7

[eluser]Gewa[/eluser]
I need just to put library in /system/libraries , or also to make some load function?

Maybe this is , that issue?

I just copy and paste this into /system/libraries as MY_Language.php

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* URI Language Identifier
*
* Adds a language identifier prefix to all site_url links
* Loads the default language file
*
* version 0.12 (c) Wiredesignz 2008-04-21
*/
class MY_Language extends CI_Language
{
    function MY_Language()
    {
        parent::CI_Language();

        global $RTR;

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

        //get the language from uri segment
        $lang_abbr = $RTR->uri->segment(1);

        //check for invalid abbreviation
        if(!isset($lang_uri_abbr[$lang_abbr]))
        {
            $base_url  = $RTR->config->item('base_url');
            $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 .= ($index_page) ? "/{$deft_abbr}" : "{$deft_abbr}";

                $uri_string = $RTR->uri->uri_string;

                //remove an invalid abbreviation from uri
                if (strlen($lang_abbr) == 2)
                {
                    $uri_string = str_replace("/{$lang_abbr}", '', $uri_string);
                }

                //redirect
                header("Location:".$base_url.$index_page.$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 .= ($index_page) ? "/{$lang_abbr}" : "{$lang_abbr}";
            }
        }

        //reset the the config index_page value
        $index_page .= ($index_page) ? '/' : '';

        $RTR->config->set_item('index_page', $index_page);

        //load the user language file
        parent::load($user_lang, $user_lang);
    }
}


?>


Messages In This Thread
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 03:24 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:24 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:28 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:38 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:41 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:47 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:49 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:53 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 04:54 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:01 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:07 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:10 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:11 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:16 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:25 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:29 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:35 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:37 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 05:38 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 04-30-2008, 06:00 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 06-01-2008, 12:45 PM
URI Language Identifier and CI 1.6.1 - by El Forum - 06-02-2008, 04:49 AM
URI Language Identifier and CI 1.6.1 - by El Forum - 06-02-2008, 06:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB