1

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?
}
steelbull
  • 131
  • 4
  • 14

3 Answers3

1

Try with:

$lang = JFactory::getLanguage();
$lang->setLanguage('sk-SK' );
$lang->load();
mokiSRB
  • 1,132
  • 7
  • 16
  • I was try this - nothing works: $lang = JFactory::getLanguage(); $lang->setDefault('en-GB'); $lang->setLanguage('en-GB'); $lang->load(); $l = JLanguage::getInstance(); $l->setLanguage('en-GB'); $l->setDefault('en-GB'); $l->load(); $app->loadLanguage(JLanguage::getInstance('en-GB')); – steelbull Apr 27 '16 at 10:52
1

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.

Francesco Abeni
  • 4,190
  • 1
  • 19
  • 30
0

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

steelbull
  • 131
  • 4
  • 14