Reputation: 141
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
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
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
Reputation: 1162
Try with:
$lang = JFactory::getLanguage();
$lang->setLanguage('sk-SK' );
$lang->load();
Upvotes: 1