1. sfI18nApplicationExtract.class.php
  2. /** * @package symfony * @subpackage i18n * @author Fabien Potencier * @version SVN: $Id: sfI18nApplicationExtract.class.php 14872 2009-01-19 08:32:06Z fabien $ */
  3. class sfI18nApplicationExtract extends sfI18nExtract
  4. {
  5. protected $extractObjects = array();
  6. /**
  7. * Configures the current extract object.
  8. */
  9. public function configure()
  10. {
  11. $this->extractObjects = array();
  12. // Modules
  13. $moduleNames = sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_app_module_dir'));
  14. foreach ($moduleNames as $moduleName)
  15. {
  16. $this->extractObjects[] = new sfI18nModuleExtract($this->i18n, $this->culture, array('module' => $moduleName));
  17. }
  18. }
  19. /**
  20. * Extracts i18n strings.
  21. *
  22. * This class must be implemented by subclasses.
  23. */
  24. public function extract()
  25. {
  26. foreach ($this->extractObjects as $extractObject)
  27. {
  28. $extractObject->extract();
  29. }
  30. // Add global templates
  31. $this->extractFromPhpFiles(sfConfig::get('sf_app_template_dir'));
  32. // Add global librairies
  33. $this->extractFromPhpFiles(sfConfig::get('sf_app_lib_dir'));
  34. }
  35. /**
  36. * Gets the current i18n strings.
  37. */
  38. public function getCurrentMessages()
  39. {
  40. return array_unique(array_merge($this->currentMessages, $this->aggregateMessages('getCurrentMessages')));
  41. }
  42. /**
  43. * Gets all i18n strings seen during the extraction process.
  44. */
  45. public function getAllSeenMessages()
  46. {
  47. return array_unique(array_merge($this->allSeenMessages, $this->aggregateMessages('getAllSeenMessages')));
  48. }
  49. protected function aggregateMessages($method)
  50. {
  51. $messages = array();
  52. foreach ($this->extractObjects as $extractObject)
  53. {
  54. $messages = array_merge($messages, $extractObject->$method());
  55. }
  56. return array_unique($messages);
  57. }
  58. }

Debug toolbar