Welcome Guest, Not a member yet? Register   Sign In
Multilanguage site with different root domains

Hi. I'm quite new to CI wonder if anyone can help me with this:

I'm building a site with three languages: english, finnish, swedish. Since we have three different domain names for the language setting I would like to use

domain.com -> english version
domain.fi -> finnish version
domain.se -> swedish version

Hence the preferred method by using uri segment 1 like the "/en/controller/method/argument" approach won't work.

The site suppose to be database driven for contents so I like to set a global variable ($lang) to use for getting the correct language specific fields from the database (ie "title_en", "title_fi" etcetera).

I wonder where to start looking for a solution. Would it be a .htaccess rewrite or a routing thing? Any suggestions?

I do this sort of thing to switch between desktop and mobile versions of my sites.

Put in your index.php:

    case 'domain.com':
    case 'www.domain.com':
        // Either
        define('LANG', 'en');
        // Or
        $GLOBALS['lang'] = 'en';
    case 'domain.fi':
    case 'www.domain.fi':
        // Either
        define('LANG', 'fi');
        // Or
        $GLOBALS['lang'] = 'fi';
    case 'domain.sw':
    case 'www.domain.sw':
        // Either
        define('LANG', 'sw');
        // Or
        $GLOBALS['lang'] = 'sw';

Then you have access to either LANG constant or $GLOBALS['lang'] variable.

YESS! Just what I needed, easy as that! Thanks a lot!

Theme © iAndrew 2016 - Forum software by © MyBB