steelbull
steelbull

Reputation: 141

Joomla change language in PHP (index.php) depend on domain name

I would like to manually set language in PHP (index.php) before load the page depend on domain name. For example I need something like this:

<?php    
$server = filter_var($_SERVER['SERVER_NAME'], FILTER_SANITIZE_STRING);
if($server == 'domain1') {
   // How can i set current language to sk-SK?
} else {
   // How can i set current language to en-GB?
}

Upvotes: 1

Views: 910

Answers (3)

Francesco Abeni
Francesco Abeni

Reputation: 4265

You can create a custom system plugin that runs onAfterInitialize and performs the requested task. See https://docs.joomla.org/J3.x:Creating_a_Plugin_for_Joomla for basic instructions on how to build a plugin.

You may want to duplicate and rename the languageFilter plugin since you were already able to make it work.

Upvotes: 1

steelbull
steelbull

Reputation: 141

I hacked the languagefilter plugin, now it works, but its not correct, because while updating Joomla to the new version file can be overwrite :-(

Upvotes: 0

mokiSRB
mokiSRB

Reputation: 1162

Try with:

$lang = JFactory::getLanguage();
$lang->setLanguage('sk-SK' );
$lang->load();

Upvotes: 1

Related Questions