Skip to content

Instantly share code, notes, and snippets.

@stranger777
Last active August 29, 2018 15:42
Show Gist options
  • Save stranger777/b3ffa367d310ee8307adeb709c61bf54 to your computer and use it in GitHub Desktop.
Save stranger777/b3ffa367d310ee8307adeb709c61bf54 to your computer and use it in GitHub Desktop.
PHP code example
<?php
interface iUserLocaleInstallerSettings
{
public function getInstallationSiteURL();
}
class RussianInstallation implements iUserLocaleInstallerSettings
{
public function getInstallationSiteURL()
{
return "https://www.1c-bitrix.ru/";
}
}
class NonRussianInstallation implements iUserLocaleInstallerSettings
{
public function getInstallationSiteURL()
{
return "http://www.bitrixsoft.com/";
}
}
class Installer
{
public function getLang()
{
$tmp = explode("_", Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']));
return $tmp[0];
}
}
//
$Inst = new Installer();
if (in_array($Inst->getLang(), array(
"by",
"ru",
"ua"
)))
{
$Installation = new RussianInstallation();
echo "No, we are russians... " . $Installation->getInstallationSiteURL();
}
else if (in_array($Inst->getLang(), array(
"en",
"de"
)))
{
$Installation = new NonRussianInstallation();
echo "Detect English Installation Server: " . $Installation->getInstallationSiteURL();
}
else
{
$Installation = new NonRussianInstallation();
echo "Other countries Installation Server: " . $Installation->getInstallationSiteURL();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment