Changeset 8453
- Timestamp:
- 04/14/08 18:39:14 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/task/i18n/sfI18nFindTask.class.php
r8452 r8453 41 41 [./symfony i18n:find frontend|INFO] 42 42 43 This task has a very limited understanding of templates and can only find simple strings like this one:43 This task is able to find non internationalized strings in pure HTML and in PHP code: 44 44 45 45 <p>Non i18n text</p> 46 <p><?php echo 'Test' ?></p> 46 47 47 But it can't find strings embedded in PHP code like this one: 48 49 <p><?php echo 'Test' ?></p> 48 As the task returns all strings embedded in PHP, you can have some false positive (especially 49 if you use the string syntax for helper arguments). 50 50 EOF; 51 51 } … … 73 73 foreach ($templates as $template) 74 74 { 75 if (!isset($strings[$template])) 76 { 77 $strings[$template] = array(); 78 } 79 75 80 $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 76 81 $content = file_get_contents($template); … … 90 95 if (!$node->isWhitespaceInElementContent()) 91 96 { 92 if (!isset($strings[$template]))93 {94 $strings[$template] = array();95 }96 97 97 $strings[$template][] = $node->nodeValue; 98 98 } … … 105 105 } 106 106 } 107 else if ('DOMProcessingInstruction' == get_class($node) && 'php' == $node->target) 108 { 109 // processing instruction node 110 $tokens = token_get_all('<?php '.$node->nodeValue); 111 foreach ($tokens as $token) 112 { 113 if (is_array($token)) 114 { 115 list($id, $text) = $token; 116 117 if (T_CONSTANT_ENCAPSED_STRING === $id) 118 { 119 $strings[$template][] = substr($text, 1, -1); 120 } 121 } 122 } 123 } 107 124 } 108 125 } … … 111 128 foreach ($strings as $template => $messages) 112 129 { 130 if (!$messages) 131 { 132 continue; 133 } 134 113 135 $this->logSection('i18n', sprintf('strings in "%s"', str_replace(sfConfig::get('sf_root_dir'), '', $template)), 1000); 114 136 foreach ($messages as $message)

