Welcome Guest, Not a member yet? Register   Sign In
i18n library in CI2
#11

[eluser]NiconPhantom[/eluser]
Thank you! This information was also helpful for me.

Is there any url helper available for this library? If I start new page http://localhost/ci2 my url looks like http://localhost/ci2/en

But if I create link anchor('something','something') insted http://localhost/ci2/en/something my url is just http://localhost/ci2/something.

Thank you in advance!
#12

[eluser]stirado[/eluser]
[quote author="n0xie" date="1290097032"]The problem is that in the latest CI2.0 build the get_instance() is a wrapper for CI_Controller::get_instance(), a static call to the (new) CI superobject instance. The i18n library does the call before the instance is created. This wasn't a problem before since get_instance() only existed if the CI_Base object was created, but since CI_Base is gone and 'replaced' by CI_Controller, the call is now done before instantiating the object.

tl;dr: new PHP4 drop screwed up loading order of things for i18n library

You can simply fix it by editing your MY_Config, which is part of the i18n library:
Code:
class MY_Config extends CI_Config {

    function site_url($uri = '')
    {    
        if (is_array($uri))
        {
            $uri = implode('/', $uri);
        }

        // make it compatible with CI 2.0
        if (class_exists('CI_Controller'))
        {
            $uri = get_instance()->lang->localized($uri);
        }
        
        return parent::site_url($uri);
    }
        
}
[/quote]

I tried this with HMVC, where MY_Config extends MX_Config, instead of CI_Config and it doesn't work.

Any suggestion?
#13

[eluser]n0xie[/eluser]
Try this:
Code:
require APPPATH."third_party/MX/Config.php";

class MY_Config extends MX_Config {
    

//class MY_Config extends CI_Config {

    function site_url($uri = '')
    {    
        if (is_array($uri))
        {
            $uri = implode('/', $uri);
        }
        
        if (class_exists('CI_Controller'))
        {
            $uri = get_instance()->lang->localized($uri);
        }

        return parent::site_url($uri);
    }
        
}




Theme © iAndrew 2016 - Forum software by © MyBB