Skip to content
Browse files

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
  • Loading branch information...
1 parent 454d58a commit 7a3be4418eaeaf48d876f37746ecf7614511215e sminnee committed Oct 13, 2010
Showing with 22 additions and 0 deletions.
  1. +22 −0 install.php
View
22 install.php
@@ -50,9 +50,24 @@
}
}
+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 @@ function install($config) {
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 @@ function install($config) {
// 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 @@ function install($config) {
// 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

0 comments on commit 7a3be44

Please sign in to comment.
Something went wrong with that request. Please try again.