Best way to set a language in CodeIgniter with URIs

Czplfjybpgdgl

New Member
I'm using CodeIgniter with po/mo files (I don't like the built-in functions). I have an already-made function that uses get variables to set the cookie with the language.Now, CodeIgniter doesn't have the get, but uses URIs. This is the function that I'm using (it fires in the constructor):\[code\]private function locale(){ $cookie_name = $this->cookie_lang; $uri = $this->uri->uri_to_assoc(3); if ($this->tools->isArray($uri)){ $locale = $uri['locale']; } if ($locale) { setcookie("$cookie_name", $locale, 0, "/"); } else { if( !isset($_COOKIE[$cookie_name]) && empty($_COOKIE[$cookie_name]) ) { setcookie("$cookie_name", 'it', 0, "/"); $locale = 'it'; } else { $locale = $_COOKIE[$cookie_name]; } } putenv("LC_ALL=$locale"); setlocale(LC_ALL, $locale); bindtextdomain("default", "./locale"); textdomain("default"); $this->locale = $locale; return true;}\[/code\]It works perfectly. Setting the language is just a matter of appending:\[code\]locale/x\[/code\]to the URL. The problem is that I use URIs for other purposes (for example loading a page)\[code\]page/x\[/code\]This results in very long URLs, like:\[code\]www.site.com/controller/method/page/x/locale/y\[/code\]just to be able to set the language.What would be an easier (or better) method to set a language?
 
Back
Top