diff options
-rw-r--r-- | core/config/locale.php | 14 | ||||
-rw-r--r-- | core/helpers/core_installer.php | 1 | ||||
-rw-r--r-- | core/libraries/I18n.php | 8 | ||||
-rw-r--r-- | installer/install.sql | 9 | ||||
-rw-r--r-- | modules/user/helpers/user_event.php | 6 | ||||
-rw-r--r-- | modules/user/helpers/user_installer.php | 1 |
6 files changed, 23 insertions, 16 deletions
diff --git a/core/config/locale.php b/core/config/locale.php index d9f95664..3cea9178 100644 --- a/core/config/locale.php +++ b/core/config/locale.php @@ -40,15 +40,7 @@ $config['timezone'] = ''; * The locale of the built-in localization messages (locale of strings in translate() calls). * This can't be changed easily, unless all localization strings are replaced in all source files * as well. + * Although the actual root is "en_US", the configured root is "en" that all en locales inherit the + * built-in strings. */ -$config['root_locale'] = 'en'; - -/** - * The default locale of this installation. - */ -$config['default_locale'] = 'en_US'; - -/** - * The path to the folder with translation files. - */ -$config['locale_dir'] = VARPATH . 'locale/';
\ No newline at end of file +$config['root_locale'] = 'en';
\ No newline at end of file diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index 7a83ec8f..e0747d46 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -207,6 +207,7 @@ class core_installer { module::set_var("core", "page_size", 9); module::set_var("core", "thumb_size", 200); module::set_var("core", "resize_size", 640); + module::set_var("core", "default_locale", "en_US"); // Add rules for generating our thumbnails and resizes graphics::add_rule( diff --git a/core/libraries/I18n.php b/core/libraries/I18n.php index 19215325..7323ea1d 100644 --- a/core/libraries/I18n.php +++ b/core/libraries/I18n.php @@ -56,7 +56,6 @@ class I18n_Core { private $_cache = array(); - private function __construct($config) { $this->_config = $config; } @@ -64,12 +63,19 @@ class I18n_Core { public static function instance($config=null) { if (self::$_instance == NULL || isset($config)) { $config = isset($config) ? $config : Kohana::config('locale'); + if (empty($config['default_locale'])) { + $config['default_locale'] = module::get_var('core', 'default_locale'); + } self::$_instance = new I18n_Core($config); } return self::$_instance; } + public function setLocale($locale) { + $this->_config['default_locale'] = $locale; + } + /** * Translates a localizable message. * @param $message String|array The message to be translated. E.g. "Hello world" diff --git a/installer/install.sql b/installer/install.sql index ba3773e7..153057f1 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -143,7 +143,7 @@ CREATE TABLE `items` ( KEY `type` (`type`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO `items` VALUES (NULL,1234166308,'Welcome to your Gallery3',NULL,1,1,1,NULL,NULL,2,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',1234166308,0,NULL,1,1); +INSERT INTO `items` VALUES (NULL,1234232381,'Welcome to your Gallery3',NULL,1,1,1,NULL,NULL,2,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',1234232381,0,NULL,1,1); DROP TABLE IF EXISTS `items_tags`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; @@ -300,12 +300,13 @@ CREATE TABLE `users` ( `guest` tinyint(1) default '0', `hash` char(32) default NULL, `url` varchar(255) default NULL, + `locale` char(10) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), UNIQUE KEY `hash` (`hash`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO `users` VALUES (1,'guest','Guest User','MGLY6511e6a900d20a0d74e270e059120353',0,0,NULL,0,1,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL); +INSERT INTO `users` VALUES (1,'guest','Guest User','[oS\\615de701682051a9970409c02c94ca94',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS `vars`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; @@ -316,6 +317,6 @@ CREATE TABLE `vars` ( `value` text, PRIMARY KEY (`id`), UNIQUE KEY `module_name` (`module_name`,`name`) -) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO `vars` VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','graphics_toolkit','imagemagick'),(7,'core','graphics_toolkit_path','/usr/bin'),(8,'core','blocks_dashboard_sidebar','a:4:{i:1010288539;a:2:{i:0;s:4:\"core\";i:1;s:11:\"block_adder\";}i:1869509477;a:2:{i:0;s:4:\"core\";i:1;s:5:\"stats\";}i:695550396;a:2:{i:0;s:4:\"core\";i:1;s:13:\"platform_info\";}i:1828086635;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(9,'core','blocks_dashboard_center','a:4:{i:184470340;a:2:{i:0;s:4:\"core\";i:1;s:7:\"welcome\";}i:111465099;a:2:{i:0;s:4:\"core\";i:1;s:12:\"photo_stream\";}i:1801799843;a:2:{i:0;s:4:\"core\";i:1;s:11:\"log_entries\";}i:1081490389;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(10,'core','version','3.0'),(11,'comment','spam_caught','0'); +INSERT INTO `vars` VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','default_locale','en_US'),(7,'core','graphics_toolkit','imagemagick'),(8,'core','graphics_toolkit_path','/usr/bin'),(9,'core','blocks_dashboard_sidebar','a:4:{i:373668224;a:2:{i:0;s:4:\"core\";i:1;s:11:\"block_adder\";}i:838141216;a:2:{i:0;s:4:\"core\";i:1;s:5:\"stats\";}i:26528;a:2:{i:0;s:4:\"core\";i:1;s:13:\"platform_info\";}i:1914449606;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(10,'core','blocks_dashboard_center','a:4:{i:551308471;a:2:{i:0;s:4:\"core\";i:1;s:7:\"welcome\";}i:412910748;a:2:{i:0;s:4:\"core\";i:1;s:12:\"photo_stream\";}i:1418841915;a:2:{i:0;s:4:\"core\";i:1;s:11:\"log_entries\";}i:690142318;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(11,'core','version','3.0'),(12,'comment','spam_caught','0'); diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php index 21848e2e..4af1d22f 100644 --- a/modules/user/helpers/user_event.php +++ b/modules/user/helpers/user_event.php @@ -23,5 +23,11 @@ class user_event_Core { */ static function gallery_ready() { user::load_user(); + + $locale = user::active()->locale; + if (!empty($locale)) { + // TODO(andy_st): Check session data as well. + I18n::instance()->setLocale($locale); + } } } diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 8f2f25a6..806ed14b 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -35,6 +35,7 @@ class user_installer { `guest` BOOLEAN default 0, `hash` char(32) default NULL, `url` varchar(255) default NULL, + `locale` char(10) default NULL, PRIMARY KEY (`id`), UNIQUE KEY(`hash`), UNIQUE KEY(`name`)) |