|
Revision 31248, 2.0 kB
(checked in by fabien, 3 years ago)
|
[1.3, 1.4] fixed sfI18nModuleExtract.class.php always assumes a file based message source (closes #9153 - patch from daReaper)
|
- 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 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
class sfI18nModuleExtract extends sfI18nExtract |
|---|
| 18 |
{ |
|---|
| 19 |
protected $module = ''; |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
* Configures the current extract object. |
|---|
| 23 |
*/ |
|---|
| 24 |
public function configure() |
|---|
| 25 |
{ |
|---|
| 26 |
if (!isset($this->parameters['module'])) |
|---|
| 27 |
{ |
|---|
| 28 |
throw new sfException('You must give a "module" parameter when extracting for a module.'); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
$this->module = $this->parameters['module']; |
|---|
| 32 |
|
|---|
| 33 |
$options = $this->i18n->getOptions(); |
|---|
| 34 |
$dirs = $this->i18n->isMessageSourceFileBased($options['source']) ? $this->i18n->getConfiguration()->getI18NDirs($this->module) : null; |
|---|
| 35 |
$this->i18n->setMessageSource($dirs, $this->culture); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
* Extracts i18n strings. |
|---|
| 40 |
* |
|---|
| 41 |
* This class must be implemented by subclasses. |
|---|
| 42 |
*/ |
|---|
| 43 |
public function extract() |
|---|
| 44 |
{ |
|---|
| 45 |
|
|---|
| 46 |
$moduleDir = sfConfig::get('sf_app_module_dir').'/'.$this->module; |
|---|
| 47 |
$this->extractFromPhpFiles(array( |
|---|
| 48 |
$moduleDir.'/actions', |
|---|
| 49 |
$moduleDir.'/lib', |
|---|
| 50 |
$moduleDir.'/templates', |
|---|
| 51 |
)); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$generator = $moduleDir.'/config/generator.yml'; |
|---|
| 55 |
if (file_exists($generator)) |
|---|
| 56 |
{ |
|---|
| 57 |
$yamlExtractor = new sfI18nYamlGeneratorExtractor(); |
|---|
| 58 |
$this->updateMessages($yamlExtractor->extract(file_get_contents($generator))); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
$validateFiles = glob($moduleDir.'/validate/*.yml'); |
|---|
| 63 |
if (is_array($validateFiles)) |
|---|
| 64 |
{ |
|---|
| 65 |
foreach ($validateFiles as $validateFile) |
|---|
| 66 |
{ |
|---|
| 67 |
$yamlExtractor = new sfI18nYamlValidateExtractor(); |
|---|
| 68 |
$this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile))); |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|