Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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: sfI18nModuleExtract.class.php 31248 2010-10-26 13:54:12Z fabien $
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
    $options = $this->i18n->getOptions();
34
    $dirs = $this->i18n->isMessageSourceFileBased($options['source']) ? $this->i18n->getConfiguration()->getI18NDirs($this->module) : null;
35
    $this->i18n->setMessageSource($dirs, $this->culture);
36
  }
37
 
38
  /**
39
   * Extracts i18n strings.
40
   *
41
   * This class must be implemented by subclasses.
42
   */
43
  public function extract()
44
  {
45
    // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories
46
    $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module;
47
    $this->extractFromPhpFiles(array(
48
      $moduleDir.'/actions',
49
      $moduleDir.'/lib',
50
      $moduleDir.'/templates',
51
    ));
52
 
53
    // Extract from generator.yml files
54
    $generator = $moduleDir.'/config/generator.yml';
55
    if (file_exists($generator))
56
    {
57
      $yamlExtractor = new sfI18nYamlGeneratorExtractor();
58
      $this->updateMessages($yamlExtractor->extract(file_get_contents($generator)));
59
    }
60
 
61
    // Extract from validate/*.yml files
62
    $validateFiles = glob($moduleDir.'/validate/*.yml');
63
    if (is_array($validateFiles))
64
    {
65
      foreach ($validateFiles as $validateFile)
66
      {
67
        $yamlExtractor = new sfI18nYamlValidateExtractor();
68
        $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile)));
69
      }
70
    }
71
  }
72
}