CodeIgniter Forums

Full Version: Internationalization
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Bramme[/eluser]
Hello everybody

I'm busy with a little portfolio website for myself, but I'd like to have it in two language: dutch and english.

At the moment, everything is working, but I could use some hints and have some questions.

My uri's look like this: example.com/lang/method.

My routes.php config file:
Code:
$route['en(.*)'] = 'content$1';
$route['nl(.*)'] = 'content$1';

My default controller, Content:
Code:
class Content extends Controller {


    function Content()
    {
        parent::Controller();    
        
        if($this->uri->segment(1) === FALSE) {
            redirect(site_url().'nl/');
        }
        
        $languages = array('en' => 'english', 'nl' => 'nederlands');
        $language = $languages[$this->uri->segment(1)];
        $this->config->set_item('language', $language);
.....

I also use a MY_url_helper.php with a rewritten anchor function that adds nl or en in front of urls depending on what is currently set in the config item.

I was wondering if anyone had anything to mention about my way: possible caveats, bugs or anything else.

Now I have one remaining question: at the moment, all my method names are in Dutch, thus forcing English speaking visitors to see urls as example.com/en/dutchmethodname. It's a matter of semantics, I know, but I'd like to translate the method names too. Copying the content controller and renaming the method names seems a bit against the DRY principle.
Am I correct to assume a _remap function is the way to go here?