Development

Changeset 6721

You must first sign up to be able to contribute.

Changeset 6721

Show
Ignore:
Timestamp:
12/26/07 21:59:02 (10 months ago)
Author:
fabien
Message:

removed i18n.yml configuration file (closes #1877, #2634)

  • removed i18n.yml file
  • moved i18n configuration to factories.yml
  • moved default culture to settings.yml
  • updated UPGRADE file
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/UPGRADE

    r6666 r6721  
    8585not singletons. 
    8686 
    87 If you want to get one of those objects in your code, they are still 
     87If you want to get one of those objects in your code, they are 
    8888available from `sfContext`: 
    8989 
     
    9393  sfContext::getInstance()->getLogger() 
    9494 
    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% 
     95Routing 
     96~~~~~~~ 
     97 
     98Here is the default configuration for the routing in `factories.yml`: 
    10799 
    108100  routing: 
     
    110102    param: 
    111103      load_configuration: true 
     104 
     105The `project:upgrade1.1` task makes all the changes for you. 
     106 
     107Logging 
     108~~~~~~~ 
     109 
     110Here is the default configuration for logging in `factories.yml`: 
    112111 
    113112  logger: 
     
    120119          param: 
    121120            condition: %SF_WEB_DEBUG% 
     121            xdebug_logging: true 
    122122        sf_file_debug: 
    123123          class: sfFileLogger 
     
    146146 
    147147The `project:upgrade1.1` task makes all those changes for you. 
     148 
     149i18n 
     150~~~~ 
     151 
     152Here 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 
     169The `i18n.yml` configuration file is not used anymore. 
     170Instead, you can configure i18n in `factories.yml`. 
     171 
     172The only exception is the `default_culture` setting which is now configurable in `settings.yml` 
     173and do not depend on the i18n framework anymore: 
     174 
     175  default_culture: en 
     176 
     177If your project has some specific settings, you must move your current configuration from the `i18n.yml` to 
     178the `factories.yml` and add the default culture in `settings.yml` as shown above. 
    148179 
    149180Cache Framework 
  • branches/1.1/data/config/factories.yml

    r6609 r6721  
    3030    class: sfI18N 
    3131    param: 
    32       load_configuration: true 
     32      source:               XLIFF 
     33      debug:                off 
     34      untranslated_prefix:  "[T]" 
     35      untranslated_suffix:  "[/T]" 
    3336      cache: 
    3437        class: sfFileCache 
  • branches/1.1/data/config/settings.yml

    r6609 r6721  
    7777    logging_enabled:        on 
    7878 
     79    # i18n 
     80    default_culture:        en        # default culture for a user 
     81 
    7982    # enable 1.0 compatibility 
    8083    compat_10:              off 
  • branches/1.1/data/skeleton/app/app/config/factories.yml

    r6365 r6721  
    4949#    class: sfI18N 
    5050#    param: 
     51#      source:              XLIFF 
     52#      debug:               off 
     53#      untranslated_prefix: "[T]" 
     54#      untranslated_suffix: "[/T]" 
    5155#      cache: 
    5256#        class: sfFileCache 
  • branches/1.1/lib/config/sfFactoryConfigHandler.class.php

    r6684 r6721  
    125125 
    126126        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)); 
    128128          break; 
    129129 
     
    152152          } 
    153153 
    154           $configuration = ''; 
    155           if (isset($parameters['load_configuration']) && $parameters['load_configuration']) 
    156           { 
    157             $configuration = "  \$this->factories['i18n']->loadConfiguration();\n"; 
    158           } 
    159154          $instances[] = sprintf("\n  if (sfConfig::get('sf_i18n'))\n  {\n". 
    160155                     "    \$class = sfConfig::get('sf_factory_i18n', '%s');\n". 
    161156                     "%s". 
    162                      "    \$this->factories['i18n'] = new \$class(\$this->dispatcher, \$cache);\n". 
    163                      $configuration. 
     157                     "    \$this->factories['i18n'] = new \$class(\$this->dispatcher, \$cache, %s);\n". 
    164158                     "  }\n" 
    165                      , $class, $cache 
     159                     , $class, $cache, var_export($parameters, true) 
    166160                     ); 
    167161          break; 
  • branches/1.1/lib/config/sfLoader.class.php

    r6509 r6721  
    134134   * Gets the i18n directories to use globally. 
    135135   * 
    136    * Returns null if the current i18n source is not a file based i18n backend (XLIFF or gettext). 
    137    * 
    138136   * @return array An array of i18n directories 
    139137   */ 
    140138  static public function getI18NGlobalDirs() 
    141139  { 
    142     if (!in_array(sfConfig::get('sf_i18n_source'), array('XLIFF', 'gettext'))) 
    143     { 
    144       return null; 
    145     } 
    146  
    147140    $dirs = array(); 
    148141 
     
    166159   * Gets the i18n directories to use for a given module. 
    167160   * 
    168    * Returns null if the current i18n source is not a file based i18n backend (XLIFF or gettext). 
    169    * 
    170161   * @param string The module name 
    171162   * 
     
    174165  static public function getI18NDirs($moduleName) 
    175166  { 
    176     if (!in_array(sfConfig::get('sf_i18n_source'), array('XLIFF', 'gettext'))) 
    177     { 
    178       return null; 
    179     } 
    180  
    181167    $dirs = array(); 
    182168 
  • branches/1.1/lib/i18n/sfI18N.class.php

    r6684 r6721  
    5555    } 
    5656 
    57     $this->options    = array_merge(array( 
     57    $this->options = array_merge(array( 
    5858      'source'              => 'XLIFF', 
    5959      'debug'               => false, 
     
    6868 
    6969  /** 
    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   /** 
    8670   * Sets the message source. 
    8771   * 
     
    126110  public function createMessageSource($dir = null) 
    127111  { 
    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']); 
    132113  } 
    133114 
     
    299280 
    300281  /** 
     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  /** 
    301296   * Listens to the user.change_culture event. 
    302297   * 
  • branches/1.1/test/unit/user/sfUserTest.php

    r6481 r6721  
    3232$t->is($user->getCulture(), 'de', '->initialize() sets the culture to the value of default_culture if available'); 
    3333 
    34 sfConfig::set('sf_i18n_default_culture', 'fr'); 
    3534user_flush($dispatcher, $user, $storage); 
    3635$t->is($user->getCulture(), 'de', '->initialize() reads the culture from the session data if available');