From 7a3be4418eaeaf48d876f37746ecf7614511215e Mon Sep 17 00:00:00 2001 From: sminnee Date: Wed, 13 Oct 2010 04:24:26 +0000 Subject: [PATCH] ENHANCEMENT you can now choose your site locale at install time (from r100769) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@112201 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- install.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/install.php b/install.php index 7fbbf4b..7a368e0 100644 --- a/install.php +++ b/install.php @@ -50,9 +50,24 @@ if($envFileExists) { } } +include_once('sapphire/core/Object.php'); +include_once('sapphire/core/i18n.php'); include_once('sapphire/dev/install/DatabaseConfigurationHelper.php'); include_once('sapphire/dev/install/DatabaseAdapterRegistry.php'); +// Set default locale, but try and sniff from the user agent +$locales = i18n::$common_locales; +$defaultLocale = 'en_US'; +if (isset($_SERVER['HTTP_USER_AGENT'])) { + foreach($locales as $code => $details) { + $bits = explode('_', $code); + if (preg_match("/{$bits[0]}.{$bits[1]}/", $_SERVER['HTTP_USER_AGENT'])) { + $defaultLocale = $code; + break; + } + } +} + // Register the SilverStripe provided databases DatabaseAdapterRegistry::register( 'MySQLDatabase', @@ -832,6 +847,7 @@ class Installer extends InstallRequirements { fclose($fh); } $theme = isset($_POST['template']) ? $_POST['template'] : 'blackcandy'; + $locale = isset($_POST['locale']) ? $_POST['locale'] : 'en_US'; // Write the config file global $usingEnv; if($usingEnv) { @@ -853,6 +869,9 @@ MySQLDatabase::set_connection_charset('utf8'); // downloaded from http://www.silverstripe.org/themes/ SSViewer::set_theme('$theme'); +// Set the site locale +i18n::set_locale($locale); + // enable nested URLs for this site (e.g. page/sub-page/) SiteTree::enable_nested_urls(); PHP @@ -892,6 +911,9 @@ MySQLDatabase::set_connection_charset('utf8'); // downloaded from http://www.silverstripe.org/themes/ SSViewer::set_theme('$theme'); +// Set the site locale +i18n::set_locale('$locale'); + // enable nested URLs for this site (e.g. page/sub-page/) SiteTree::enable_nested_urls(); PHP