1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- /*
- * This file is part of the symfony package.
- * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- /**
- * @package symfony
- * @subpackage i18n
- * @author Fabien Potencier <fabien.potencier@symfony-project.com>
- * @version SVN: $Id: sfI18nModuleExtract.class.php 7691 2008-02-29 16:56:22Z fabien $
- */
- class sfI18nModuleExtract extends sfI18nExtract
- {
- protected $module = '';
- /**
- * Configures the current extract object.
- */
- public function configure()
- {
- if (!isset($this->parameters['module']))
- {
- throw new sfException('You must give a "module" parameter when extracting for a module.');
- }
- $this->module = $this->parameters['module'];
- $this->i18n->setMessageSource($this->i18n->getConfiguration()->getI18NDirs($this->module), $this->culture);
- }
- /**
- * Extracts i18n strings.
- *
- * This class must be implemented by subclasses.
- */
- public function extract()
- {
- // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories
- $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module;
- $this->extractFromPhpFiles(array(
- $moduleDir.'/actions',
- $moduleDir.'/lib',
- $moduleDir.'/templates',
- ));
- // Extract from generator.yml files
- $generator = $moduleDir.'/config/generator.yml';
- if (file_exists($generator))
- {
- $yamlExtractor = new sfI18nYamlGeneratorExtractor();
- $this->updateMessages($yamlExtractor->extract(file_get_contents($generator)));
- }
- // Extract from validate/*.yml files
- $validateFiles = glob($moduleDir.'/validate/*.yml');
- if (is_array($validateFiles))
- {
- foreach ($validateFiles as $validateFile)
- {
- $yamlExtractor = new sfI18nYamlValidateExtractor();
- $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile)));
- }
- }
- }
- }
|