Changeset 6721
- Timestamp:
- 12/26/07 21:59:02 (10 months ago)
- Files:
-
- branches/1.1/UPGRADE (modified) (5 diffs)
- branches/1.1/data/config/factories.yml (modified) (1 diff)
- branches/1.1/data/config/i18n.yml (deleted)
- branches/1.1/data/config/settings.yml (modified) (1 diff)
- branches/1.1/data/skeleton/app/app/config/factories.yml (modified) (1 diff)
- branches/1.1/data/skeleton/app/app/config/i18n.yml (deleted)
- branches/1.1/lib/config/sfFactoryConfigHandler.class.php (modified) (2 diffs)
- branches/1.1/lib/config/sfLoader.class.php (modified) (3 diffs)
- branches/1.1/lib/i18n/sfI18N.class.php (modified) (4 diffs)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/config/i18n.yml (deleted)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/backend/config/i18n.yml (deleted)
- branches/1.1/lib/plugins/sfPropelPlugin/test/functional/fixtures/apps/crud/config/i18n.yml (deleted)
- branches/1.1/test/functional/fixtures/project/apps/cache/config/i18n.yml (deleted)
- branches/1.1/test/functional/fixtures/project/apps/frontend/config/i18n.yml (deleted)
- branches/1.1/test/functional/fixtures/project/apps/i18n/config/i18n.yml (deleted)
- branches/1.1/test/unit/user/sfUserTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/UPGRADE
r6666 r6721 85 85 not singletons. 86 86 87 If you want to get one of those objects in your code, they are still87 If you want to get one of those objects in your code, they are 88 88 available from `sfContext`: 89 89 … … 93 93 sfContext::getInstance()->getLogger() 94 94 95 Here is their default configuration in `factories.yml`: 96 97 i18n: 98 class: sfI18N 99 param: 100 cache: 101 class: sfFileCache 102 param: 103 automatic_cleaning_factor: 0 104 cache_dir: %SF_I18N_CACHE_DIR% 105 lifetime: 86400 106 prefix: %SF_APP_DIR% 95 Routing 96 ~~~~~~~ 97 98 Here is the default configuration for the routing in `factories.yml`: 107 99 108 100 routing: … … 110 102 param: 111 103 load_configuration: true 104 105 The `project:upgrade1.1` task makes all the changes for you. 106 107 Logging 108 ~~~~~~~ 109 110 Here is the default configuration for logging in `factories.yml`: 112 111 113 112 logger: … … 120 119 param: 121 120 condition: %SF_WEB_DEBUG% 121 xdebug_logging: true 122 122 sf_file_debug: 123 123 class: sfFileLogger … … 146 146 147 147 The `project:upgrade1.1` task makes all those changes for you. 148 149 i18n 150 ~~~~ 151 152 Here is the default configuration for i18n in `factories.yml`: 153 154 i18n: 155 class: sfI18N 156 param: 157 source: XLIFF 158 debug: off 159 untranslated_prefix: "[T]" 160 untranslated_suffix: "[/T]" 161 cache: 162 class: sfFileCache 163 param: 164 automatic_cleaning_factor: 0 165 cache_dir: %SF_I18N_CACHE_DIR% 166 lifetime: 86400 167 prefix: %SF_APP_DIR% 168 169 The `i18n.yml` configuration file is not used anymore. 170 Instead, you can configure i18n in `factories.yml`. 171 172 The only exception is the `default_culture` setting which is now configurable in `settings.yml` 173 and do not depend on the i18n framework anymore: 174 175 default_culture: en 176 177 If your project has some specific settings, you must move your current configuration from the `i18n.yml` to 178 the `factories.yml` and add the default culture in `settings.yml` as shown above. 148 179 149 180 Cache Framework branches/1.1/data/config/factories.yml
r6609 r6721 30 30 class: sfI18N 31 31 param: 32 load_configuration: true 32 source: XLIFF 33 debug: off 34 untranslated_prefix: "[T]" 35 untranslated_suffix: "[/T]" 33 36 cache: 34 37 class: sfFileCache branches/1.1/data/config/settings.yml
r6609 r6721 77 77 logging_enabled: on 78 78 79 # i18n 80 default_culture: en # default culture for a user 81 79 82 # enable 1.0 compatibility 80 83 compat_10: off branches/1.1/data/skeleton/app/app/config/factories.yml
r6365 r6721 49 49 # class: sfI18N 50 50 # param: 51 # source: XLIFF 52 # debug: off 53 # untranslated_prefix: "[T]" 54 # untranslated_suffix: "[/T]" 51 55 # cache: 52 56 # class: sfFileCache branches/1.1/lib/config/sfFactoryConfigHandler.class.php
r6684 r6721 125 125 126 126 case 'user': 127 $instances[] = sprintf(" \$class = sfConfig::get('sf_factory_user', '%s');\n \$this->factories['user'] = new \$class(\$this->dispatcher, \$this->factories['storage'], array_merge(array('auto_shutdown' => false, 'culture' => \$this->factories['request']->getParameter('sf_culture'), 'default_culture' => sfConfig::get('sf_ i18n_default_culture'), 'use_flash' => sfConfig::get('sf_use_flash'), 'logging' => sfConfig::get('sf_logging_enabled')), sfConfig::get('sf_factory_user_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true));127 $instances[] = sprintf(" \$class = sfConfig::get('sf_factory_user', '%s');\n \$this->factories['user'] = new \$class(\$this->dispatcher, \$this->factories['storage'], array_merge(array('auto_shutdown' => false, 'culture' => \$this->factories['request']->getParameter('sf_culture'), 'default_culture' => sfConfig::get('sf_default_culture', 'en'), 'use_flash' => sfConfig::get('sf_use_flash'), 'logging' => sfConfig::get('sf_logging_enabled')), sfConfig::get('sf_factory_user_parameters', %s)));", $class, var_export(is_array($parameters) ? $parameters : array(), true)); 128 128 break; 129 129 … … 152 152 } 153 153 154 $configuration = '';155 if (isset($parameters['load_configuration']) && $parameters['load_configuration'])156 {157 $configuration = " \$this->factories['i18n']->loadConfiguration();\n";158 }159 154 $instances[] = sprintf("\n if (sfConfig::get('sf_i18n'))\n {\n". 160 155 " \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 161 156 "%s". 162 " \$this->factories['i18n'] = new \$class(\$this->dispatcher, \$cache);\n". 163 $configuration. 157 " \$this->factories['i18n'] = new \$class(\$this->dispatcher, \$cache, %s);\n". 164 158 " }\n" 165 , $class, $cache 159 , $class, $cache, var_export($parameters, true) 166 160 ); 167 161 break; branches/1.1/lib/config/sfLoader.class.php
r6509 r6721 134 134 * Gets the i18n directories to use globally. 135 135 * 136 * Returns null if the current i18n source is not a file based i18n backend (XLIFF or gettext).137 *138 136 * @return array An array of i18n directories 139 137 */ 140 138 static public function getI18NGlobalDirs() 141 139 { 142 if (!in_array(sfConfig::get('sf_i18n_source'), array('XLIFF', 'gettext')))143 {144 return null;145 }146 147 140 $dirs = array(); 148 141 … … 166 159 * Gets the i18n directories to use for a given module. 167 160 * 168 * Returns null if the current i18n source is not a file based i18n backend (XLIFF or gettext).169 *170 161 * @param string The module name 171 162 * … … 174 165 static public function getI18NDirs($moduleName) 175 166 { 176 if (!in_array(sfConfig::get('sf_i18n_source'), array('XLIFF', 'gettext')))177 {178 return null;179 }180 181 167 $dirs = array(); 182 168 branches/1.1/lib/i18n/sfI18N.class.php
r6684 r6721 55 55 } 56 56 57 $this->options = array_merge(array(57 $this->options = array_merge(array( 58 58 'source' => 'XLIFF', 59 59 'debug' => false, … … 68 68 69 69 /** 70 * Loads i18n configuration.71 */72 public function loadConfiguration()73 {74 include(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/i18n.yml'));75 76 $this->options = array_merge($this->options, array(77 'source' => sfConfig::get('sf_i18n_source'),78 'database' => sfConfig::get('sf_i18n_database'),79 'debug' => sfConfig::get('sf_debug') && sfConfig::get('sf_i18n_debug'),80 'untranslated_prefix' => sfConfig::get('sf_i18n_untranslated_prefix'),81 'untranslated_suffix' => sfConfig::get('sf_i18n_untranslated_suffix'),82 ));83 }84 85 /**86 70 * Sets the message source. 87 71 * … … 126 110 public function createMessageSource($dir = null) 127 111 { 128 $class = 'sfMessageSource_'.$this->options['source']; 129 $source = class_exists($class) && is_subclass_of($class, 'sfMessageSource_Database') ? $this->options['database'] : $dir; 130 131 return sfMessageSource::factory($this->options['source'], $source); 112 return sfMessageSource::factory($this->options['source'], self::isMessageSourceFileBased($this->options['source']) ? $dir : $this->options['database']); 132 113 } 133 114 … … 299 280 300 281 /** 282 * Returns true if messages are stored in a file. 283 * 284 * @param string The source name 285 * 286 * @return Boolean true if messages are stored in a file, false otherwise 287 */ 288 static public function isMessageSourceFileBased($source) 289 { 290 $class = 'sfMessageSource_'.$source; 291 292 return class_exists($class) && is_subclass_of($class, 'sfMessageSource_File'); 293 } 294 295 /** 301 296 * Listens to the user.change_culture event. 302 297 * branches/1.1/test/unit/user/sfUserTest.php
r6481 r6721 32 32 $t->is($user->getCulture(), 'de', '->initialize() sets the culture to the value of default_culture if available'); 33 33 34 sfConfig::set('sf_i18n_default_culture', 'fr');35 34 user_flush($dispatcher, $user, $storage); 36 35 $t->is($user->getCulture(), 'de', '->initialize() reads the culture from the session data if available');