/** * Extracts i18n strings. * * This class must be implemented by subclasses. */ public function extract() { // Extract from PHP files to find __() calls in actions/ lib/ and templates/ directories $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $this->module; $this->extractFromPhpFiles(array($moduleDir . '/actions', $moduleDir . '/lib', $moduleDir . '/templates')); // Extract from generator.yml files $generator = $moduleDir . '/config/generator.yml'; if (file_exists($generator)) { $yamlExtractor = new sfI18nYamlGeneratorExtractor(); $this->updateMessages($yamlExtractor->extract(file_get_contents($generator))); } // Extract from validate/*.yml files $validateFiles = glob($moduleDir . '/validate/*.yml'); if (is_array($validateFiles)) { foreach ($validateFiles as $validateFile) { $yamlExtractor = new sfI18nYamlValidateExtractor(); $this->updateMessages($yamlExtractor->extract(file_get_contents($validateFile))); } } }
/* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once(dirname(__FILE__).'/../../../bootstrap/unit.php'); $t = new lime_test(2); // __construct() $t->diag('__construct()'); $e = new sfI18nYamlValidateExtractor(); $t->ok($e instanceof sfI18nExtractorInterface, 'sfI18nYamlValidateExtractor implements the sfI18nExtractorInterface interface'); // ->extract(); $t->diag('->extract()'); $content = <<<EOF fields: name: required: msg: Name is required sfStringValidator: min_error: The name is too short validators: myStringValidator:
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../../bootstrap/unit.php'; $t = new lime_test(2, new lime_output_color()); // __construct() $t->diag('__construct()'); $e = new sfI18nYamlValidateExtractor(); $t->ok($e instanceof sfI18nExtractorInterface, 'sfI18nYamlValidateExtractor implements the sfI18nExtractorInterface interface'); // ->extract(); $t->diag('->extract()'); $content = <<<EOF fields: name: required: msg: Name is required sfStringValidator: min_error: The name is too short validators: myStringValidator: class: sfStringValidator param: min_error: The name is really too short max_error: The name is really too long