Changeset 19777
- Timestamp:
- 07/01/09 12:14:21 (4 years ago)
- Files:
-
- branches/1.0/lib/i18n/sfMessageSource_XLIFF.class.php (modified) (1 diff)
- branches/1.1/lib/i18n/sfMessageSource_XLIFF.class.php (modified) (1 diff)
- branches/1.1/test/unit/i18n/sfMessageSource_XLIFFTest.php (modified) (3 diffs)
- branches/1.2/lib/i18n/sfMessageSource_XLIFF.class.php (modified) (1 diff)
- branches/1.2/test/unit/i18n/sfMessageSource_XLIFFTest.php (modified) (3 diffs)
- branches/1.3/lib/i18n/sfMessageSource_XLIFF.class.php (modified) (1 diff)
- branches/1.3/test/unit/i18n/sfMessageSource_XLIFFTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/lib/i18n/sfMessageSource_XLIFF.class.php
r9806 r19777 68 68 protected function &loadData($filename) 69 69 { 70 //load it.71 72 $XML = simplexml_load_file($filename);73 74 if (!$XML) 75 {76 return false;77 }78 79 $translationUnit = $ XML->xpath('//trans-unit');70 libxml_use_internal_errors(true); 71 if (!$xml = simplexml_load_file($filename)) 72 { 73 $error = false; 74 75 return $error; 76 } 77 libxml_use_internal_errors(false); 78 79 $translationUnit = $xml->xpath('//trans-unit'); 80 80 81 81 $translations = array(); branches/1.1/lib/i18n/sfMessageSource_XLIFF.class.php
r13419 r19777 47 47 * 48 48 * @param string $filename XLIFF file. 49 * @return array of messages.49 * @return array|false An array of messages or false if there was a problem loading the file. 50 50 */ 51 51 public function &loadData($filename) 52 52 { 53 $XML = simplexml_load_file($filename); 54 55 if (!$XML) 56 { 57 return false; 58 } 59 60 $translationUnit = $XML->xpath('//trans-unit'); 53 libxml_use_internal_errors(true); 54 if (!$xml = simplexml_load_file($filename)) 55 { 56 $error = false; 57 58 return $error; 59 } 60 libxml_use_internal_errors(false); 61 62 $translationUnit = $xml->xpath('//trans-unit'); 61 63 62 64 $translations = array(); branches/1.1/test/unit/i18n/sfMessageSource_XLIFFTest.php
r9805 r19777 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 0, new lime_output_color());13 $t = new lime_test(11, new lime_output_color()); 14 14 15 15 // setup … … 20 20 // copy fixtures to tmp directory 21 21 copy(dirname(__FILE__).'/fixtures/messages.fr.xml', $temp.'/messages.fr.xml'); 22 copy(dirname(__FILE__).'/fixtures/invalid.xml', $temp.'/invalid.xml'); 22 23 23 24 $source = sfMessageSource::factory('XLIFF', $temp); … … 28 29 $messages = $source->loadData($source->getSource('messages.fr.xml')); 29 30 $t->is($messages['an english sentence'][0], 'une phrase en français', '->loadData() loads messages from a XLIFF file'); 31 32 $t->is($source->loadData($source->getSource('invalid.xml')), false, '->loadData() returns false if it cannot load the messages from the file'); 30 33 31 34 // ->save() branches/1.2/lib/i18n/sfMessageSource_XLIFF.class.php
r13419 r19777 47 47 * 48 48 * @param string $filename XLIFF file. 49 * @return array of messages.49 * @return array|false An array of messages or false if there was a problem loading the file. 50 50 */ 51 51 public function &loadData($filename) 52 52 { 53 $XML = simplexml_load_file($filename); 54 55 if (!$XML) 56 { 57 return false; 58 } 59 60 $translationUnit = $XML->xpath('//trans-unit'); 53 libxml_use_internal_errors(true); 54 if (!$xml = simplexml_load_file($filename)) 55 { 56 $error = false; 57 58 return $error; 59 } 60 libxml_use_internal_errors(false); 61 62 $translationUnit = $xml->xpath('//trans-unit'); 61 63 62 64 $translations = array(); branches/1.2/test/unit/i18n/sfMessageSource_XLIFFTest.php
r9805 r19777 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 0, new lime_output_color());13 $t = new lime_test(11, new lime_output_color()); 14 14 15 15 // setup … … 20 20 // copy fixtures to tmp directory 21 21 copy(dirname(__FILE__).'/fixtures/messages.fr.xml', $temp.'/messages.fr.xml'); 22 copy(dirname(__FILE__).'/fixtures/invalid.xml', $temp.'/invalid.xml'); 22 23 23 24 $source = sfMessageSource::factory('XLIFF', $temp); … … 28 29 $messages = $source->loadData($source->getSource('messages.fr.xml')); 29 30 $t->is($messages['an english sentence'][0], 'une phrase en français', '->loadData() loads messages from a XLIFF file'); 31 32 $t->is($source->loadData($source->getSource('invalid.xml')), false, '->loadData() returns false if it cannot load the messages from the file'); 30 33 31 34 // ->save() branches/1.3/lib/i18n/sfMessageSource_XLIFF.class.php
r13419 r19777 47 47 * 48 48 * @param string $filename XLIFF file. 49 * @return array of messages.49 * @return array|false An array of messages or false if there was a problem loading the file. 50 50 */ 51 51 public function &loadData($filename) 52 52 { 53 $XML = simplexml_load_file($filename); 54 55 if (!$XML) 56 { 57 return false; 58 } 59 60 $translationUnit = $XML->xpath('//trans-unit'); 53 libxml_use_internal_errors(true); 54 if (!$xml = simplexml_load_file($filename)) 55 { 56 $error = false; 57 58 return $error; 59 } 60 libxml_use_internal_errors(false); 61 62 $translationUnit = $xml->xpath('//trans-unit'); 61 63 62 64 $translations = array(); branches/1.3/test/unit/i18n/sfMessageSource_XLIFFTest.php
r19531 r19777 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test(1 0);13 $t = new lime_test(11); 14 14 15 15 // setup … … 20 20 // copy fixtures to tmp directory 21 21 copy(dirname(__FILE__).'/fixtures/messages.fr.xml', $temp.'/messages.fr.xml'); 22 copy(dirname(__FILE__).'/fixtures/invalid.xml', $temp.'/invalid.xml'); 22 23 23 24 $source = sfMessageSource::factory('XLIFF', $temp); … … 28 29 $messages = $source->loadData($source->getSource('messages.fr.xml')); 29 30 $t->is($messages['an english sentence'][0], 'une phrase en français', '->loadData() loads messages from a XLIFF file'); 31 32 $t->is($source->loadData($source->getSource('invalid.xml')), false, '->loadData() returns false if it cannot load the messages from the file'); 30 33 31 34 // ->save()