Jump to content

how to change actual website language in hooks


jogorek

Recommended Posts

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

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

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

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

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 !

Link to comment
Share on other sites

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated