Development

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

You must first sign up to be able to contribute.

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

Revision 14872, 2.0 kB (checked in by fabien, 5 years ago)

[1.1, 1.2, 1.3] fixed typo (closes #5601)

  • 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 sfI18nApplicationExtract extends sfI18nExtract
18 {
19   protected $extractObjects = array();
20
21   /**
22    * Configures the current extract object.
23    */
24   public function configure()
25   {
26     $this->extractObjects = array();
27
28     // Modules
29     $moduleNames = sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_app_module_dir'));
30     foreach ($moduleNames as $moduleName)
31     {
32       $this->extractObjects[] = new sfI18nModuleExtract($this->i18n, $this->culture, array('module' => $moduleName));
33     }
34   }
35
36   /**
37    * Extracts i18n strings.
38    *
39    * This class must be implemented by subclasses.
40    */
41   public function extract()
42   {
43     foreach ($this->extractObjects as $extractObject)
44     {
45       $extractObject->extract();
46     }
47
48     // Add global templates
49     $this->extractFromPhpFiles(sfConfig::get('sf_app_template_dir'));
50
51     // Add global librairies
52     $this->extractFromPhpFiles(sfConfig::get('sf_app_lib_dir'));
53   }
54
55   /**
56    * Gets the current i18n strings.
57    */
58   public function getCurrentMessages()
59   {
60     return array_unique(array_merge($this->currentMessages, $this->aggregateMessages('getCurrentMessages')));
61   }
62
63   /**
64    * Gets all i18n strings seen during the extraction process.
65    */
66   public function getAllSeenMessages()
67   {
68     return array_unique(array_merge($this->allSeenMessages, $this->aggregateMessages('getAllSeenMessages')));
69   }
70
71   protected function aggregateMessages($method)
72   {
73     $messages = array();
74     foreach ($this->extractObjects as $extractObject)
75     {
76       $messages = array_merge($messages, $extractObject->$method());
77     }
78
79     return array_unique($messages);
80   }
81 }
82
Note: See TracBrowser for help on using the browser.