PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/Group-I/jobeet/lib/vendor/symfony/lib/i18n/extract/sfI18nModuleExtract.class.php

https://bitbucket.org/hosseinzolfi/db-lab-spring-2011/
PHP | 72 lines | 40 code | 8 blank | 24 comment | 3 complexity | b87db465dd921d1eccc90c698d5b718d MD5 | raw file
Possible License(s): ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * @package symfony
  11. * @subpackage i18n
  12. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  13. * @version SVN: $Id: sfI18nModuleExtract.class.php 31248 2010-10-26 13:54:12Z fabien $
  14. */
  15. class sfI18nModuleExtract extends sfI18nExtract
  16. {
  17. protected $module = '';
  18. /**
  19. * Configures the current extract object.
  20. */
  21. public function configure()
  22. {
  23. if (!isset($this->parameters['module']))
  24. {
  25. throw new sfException('You must give a "module" parameter when extracting for a module.');
  26. }
  27. $this->module = $this->parameters['module'];
  28. $options = $this->i18n->getOptions();
  29. $dirs = $this->i18n->isMessageSourceFileBased($options['source']) ? $this->i18n->getConfiguration()->getI18NDirs($this->module) : null;
  30. $this->i18n->setMessageSource($dirs, $this->culture);
  31. }
  32. /**
  33. * Extracts i18n strings.
  34. *
  35. * This class must be implemented by subclasses.
  36. */
  37. public function extract()
  38. {
  39. // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories
  40. $moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module;
  41. $this->extractFromPhpFiles(array(
  42. $moduleDir.'/actions',
  43. $moduleDir.'/lib',
  44. $moduleDir.'/templates',
  45. ));
  46. // Extract from generator.yml files
  47. $generator = $moduleDir.'/config/generator.yml';
  48. if (file_exists($generator))
  49. {
  50. $yamlExtractor = new sfI18nYamlGeneratorExtractor();
  51. $this->updateMessages($yamlExtractor->extract(file_get_contents($generator)));
  52. }
  53. // Extract from validate/*.yml files
  54. $validateFiles = glob($moduleDir.'/validate/*.yml');
  55. if (is_array($validateFiles))
  56. {
  57. foreach ($validateFiles as $validateFile)
  58. {
  59. $yamlExtractor = new sfI18nYamlValidateExtractor();
  60. $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile)));
  61. }
  62. }
  63. }
  64. }