| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 49 |
$this->extractFromPhpFiles(sfConfig::get('sf_app_template_dir')); |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 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 |
|
|---|