CI 2.0 internationalization of site_url() problem |
[eluser]Juris Malinens[/eluser]
Hi! I am using http://maestric.com/doc/php/codeigniter_i18n but it not worked by default and I modified it so now /en/test1 and /ru/test1 correctly shows English and Russian language but this code: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Doesn't override site_url() function and when I use <p><?=anchor('music','Shania Twain')?></p> I get /music not /en/music or /ru/music MY_Lang.php: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
[eluser]InsiteFX[/eluser]
site_url is in the url_helper.php Did you load the url helper? If you need to change the site_url you need to create a MY_url_helper.php. InsiteFX
[eluser]Juris Malinens[/eluser]
[quote author="InsiteFX" date="1289934865"]site_url is in the url_helper.php Did you load the url helper? If you need to change the site_url you need to create a MY_url_helper.php. InsiteFX[/quote] Thank You! Created MY_url_helper.php and added this code: Code: function site_url($uri = '') And now it does what I need =)
[eluser]JulianM[/eluser]
Thanks. It worked for me after I added a missing line at the end. Code: return $uri;
[eluser]Unknown[/eluser]
[quote author="InsiteFX" date="1289934865"]site_url is in the url_helper.php Did you load the url helper? If you need to change the site_url you need to create a MY_url_helper.php. InsiteFX[/quote] I'm sorry to say but this is bad advise. Both the helper and the config class host site_url. What hat you want to do is to alter the method in de the config class instead of creating an extra function on top of it. In this case the result will be that both method/function will be executed end u end up with sandwiched url's when you use site_url like "en/site/page/en/site/page" It took me several hours of debugging to find out what was going on. The main problem is the i18n class. It contains a few bugs and loops that will give you the CI_Controller 210 error. Hope this helps. I will attach the Codeigniter 2.0 + HMVC ready files. Hope someone will find them useful and safe a few hours. |
Welcome Guest, Not a member yet? Register Sign In |