CodeIgniter Forums
Change default language depending domain name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Change default language depending domain name (/thread-55974.html)



Change default language depending domain name - El Forum - 11-19-2012

[eluser]Unknown[/eluser]
Hi,
I have 1 hosting and 2 domains. Depending the domain name I want to load a default language but I can't. When I enter with the 2 differents domains CI load the same default language.
Is there a way to change de default language?


Change default language depending domain name - El Forum - 11-19-2012

[eluser]Aken[/eluser]
Just add some code to application/config/config.php where the language is set.


Change default language depending domain name - El Forum - 11-19-2012

[eluser]PhilTem[/eluser]
Put something like this into APPPATH . 'config/autoload.php'

Code:
$autoload['language'] = array($_SERVER['HTTP_HOST'] ? : $_SERVER['SERVER_NAME'])

which will load files
example.com_lang.php on example.com (or maybe www.example.com_lang.php on example.com and www.example.com respectively)
and
example.de_lang.php on example.de

You need to play with the argument $_SERVER['HTTP_HOST'] and maybe trim some parts from it or change the string somehow so that it is uniquely identified for both http://www.example.com and http://example.com (as well as maybe https://...)

But this should guide you towards one solution.


Change default language depending domain name - El Forum - 11-19-2012

[eluser]Aken[/eluser]
Phil, that still doesn't specify what language is needed.