1. sfI18nModuleExtract.class.php
  2. /** * @package symfony * @subpackage i18n * @author Fabien Potencier * @version SVN: $Id: sfI18nModuleExtract.class.php 7691 2008-02-29 16:56:22Z fabien $ */
  3. class sfI18nModuleExtract extends sfI18nExtract
  4. {
  5. protected $module = '';
  6. /**
  7. * Configures the current extract object.
  8. */
  9. public function configure()
  10. {
  11. if (!isset($this->parameters['module']))
  12. {
  13. throw new sfException('You must give a "module" parameter when extracting for a module.');
  14. }
  15. $this->module = $this->parameters['module'];
  16. $this->i18n->setMessageSource($this->i18n->getConfiguration()->getI18NDirs($this->module), $this->culture);
  17. }
  18. /**
  19. * Extracts i18n strings.
  20. *
  21. * This class must be implemented by subclasses.
  22. */
  23. public function extract()
  24. {
  25. // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories
  26. $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module;
  27. $this->extractFromPhpFiles(array(
  28. $moduleDir.'/actions',
  29. $moduleDir.'/lib',
  30. $moduleDir.'/templates',
  31. ));
  32. // Extract from generator.yml files
  33. $generator = $moduleDir.'/config/generator.yml';
  34. if (file_exists($generator))
  35. {
  36. $yamlExtractor = new sfI18nYamlGeneratorExtractor();
  37. $this->updateMessages($yamlExtractor->extract(file_get_contents($generator)));
  38. }
  39. // Extract from validate/*.yml files
  40. $validateFiles = glob($moduleDir.'/validate/*.yml');
  41. if (is_array($validateFiles))
  42. {
  43. foreach ($validateFiles as $validateFile)
  44. {
  45. $yamlExtractor = new sfI18nYamlValidateExtractor();
  46. $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile)));
  47. }
  48. }
  49. }
  50. }

Debug toolbar