Development

/branches/1.2/lib/i18n/extract/sfI18nModuleExtract.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/i18n/extract/sfI18nModuleExtract.class.php

Revision 7691, 1.9 kB (checked in by fabien, 6 years ago)

simplified directory structure customization

  • removed *_dir_name constantsi
  • added methods to change the directory structure of a symfony application
    • setRootDir()
    • setCacheDir()
    • setLogDir()
    • setWebDir()
    • setAppDir()
  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * @package    symfony
13  * @subpackage i18n
14  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
15  * @version    SVN: $Id$
16  */
17 class sfI18nModuleExtract extends sfI18nExtract
18 {
19   protected $module = '';
20
21   /**
22    * Configures the current extract object.
23    */
24   public function configure()
25   {
26     if (!isset($this->parameters['module']))
27     {
28       throw new sfException('You must give a "module" parameter when extracting for a module.');
29     }
30
31     $this->module = $this->parameters['module'];
32
33     $this->i18n->setMessageSource($this->i18n->getConfiguration()->getI18NDirs($this->module), $this->culture);
34   }
35
36   /**
37    * Extracts i18n strings.
38    *
39    * This class must be implemented by subclasses.
40    */
41   public function extract()
42   {
43     // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories
44     $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module;
45     $this->extractFromPhpFiles(array(
46       $moduleDir.'/actions',
47       $moduleDir.'/lib',
48       $moduleDir.'/templates',
49     ));
50
51     // Extract from generator.yml files
52     $generator = $moduleDir.'/config/generator.yml';
53     if (file_exists($generator))
54     {
55       $yamlExtractor = new sfI18nYamlGeneratorExtractor();
56       $this->updateMessages($yamlExtractor->extract(file_get_contents($generator)));
57     }
58
59     // Extract from validate/*.yml files
60     $validateFiles = glob($moduleDir.'/validate/*.yml');
61     if (is_array($validateFiles))
62     {
63       foreach ($validateFiles as $validateFile)
64       {
65         $yamlExtractor = new sfI18nYamlValidateExtractor();
66         $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile)));
67       }
68     }
69   }
70 }
71
Note: See TracBrowser for help on using the browser.