jogorek Posted January 10, 2018 Share Posted January 10, 2018 Hi guys, I'm writing a hook which recognize on what subdomain is user and if he is for example on ru.domain.com I want to set up actual language to russian. How can I do it? What I did (and what is working) is I'm setting up $_SESSION['Language'] but that need a redirect to be applied and this is quite problematic. It works fine but for example Google Adwords doesnt allow for such redirects and block our ads. So I'm wondering how can I change actual language without $_SESSION, is there any other way? Link to comment Share on other sites More sharing options...
sentq Posted January 10, 2018 Share Posted January 10, 2018 done many times before, you need to use $_GET['language'] or $_REQUEST['language'] inside configuration.php file it self this way no redirect required Link to comment Share on other sites More sharing options...
jogorek Posted January 10, 2018 Author Share Posted January 10, 2018 Hm, I'm already using $_GET['language'] but still dont know how to change a language on the website. I mean, in hooks I do it like this: if ($_SERVER['HTTP_HOST'] == 'ru.domain.com') { $_SESSION['Language'] = 'russian'; header('HTTP/1.1 301 Moved Permanently'); header('Location: /'); exit; } but that need redirection becouse of $_SESSION, how you do it in configuration.php? Dont you use $_SESSION['Language'] ? So what diffrent variable store actual language so I can set it up? Link to comment Share on other sites More sharing options...
sentq Posted January 10, 2018 Share Posted January 10, 2018 try this code inside configuration.php file, also remove the ActionHook code for now: if ($_SERVER['HTTP_HOST'] == 'ru.domain.com') { $_GET['language'] = 'russian'; } this way no redirection required, you can even specify different template for each domain in the same way Link to comment Share on other sites More sharing options...
jogorek Posted January 10, 2018 Author Share Posted January 10, 2018 That is wired. I did that but it just doesnt work. I removed my hook and tried set up $_GET['language'] = 'russian'; in the begining of configuration.php (even without additional conditions), but it doesnt change the language. My version of WHMCS is 7.1.2 - does it matter? Oh, btw. thank you very much for your time and assistence! Link to comment Share on other sites More sharing options...
jogorek Posted January 10, 2018 Author Share Posted January 10, 2018 OK, problem solved. $_GET doesnt work, $_REQUEST works like a charm. So finally I put something like this to configuration.php: if ($_SERVER['HTTP_HOST'] == 'ru.domain.com') { $_REQUEST['language'] = 'russian'; } Thank you very much sentq ! 1 Link to comment Share on other sites More sharing options...
sentq Posted January 10, 2018 Share Posted January 10, 2018 4 hours ago, jogorek said: OK, problem solved. $_GET doesnt work, $_REQUEST works like a charm. So finally I put something like this to configuration.php: if ($_SERVER['HTTP_HOST'] == 'ru.domain.com') { $_REQUEST['language'] = 'russian'; } Thank you very much sentq ! glad it works Link to comment Share on other sites More sharing options...
Recommended Posts