Skip to content
This repository
Browse code

MINOR Don't break on empty YAML files

  • Loading branch information...
commit ef5e6394d6d19bfb906647e79a66bfc5d0d6ccb4 1 parent a452b6a
Ingo Schommer authored April 15, 2012
4  thirdparty/zend_translate_railsyaml/library/Translate/Adapter/RailsYAML.php
@@ -50,7 +50,7 @@ protected function _loadTranslationData($data, $locale, array $options = array()
50 50
         }
51 51
 
52 52
         $content = sfYaml::load(file_get_contents($this->_filename));
53  
-        if($locale != 'auto' && !array_key_exists($locale, $content)) {
  53
+        if($locale != 'auto' && $content && !array_key_exists($locale, $content)) {
54 54
             require_once 'Zend/Translate/Exception.php';
55 55
             throw new Zend_Translate_Exception(sprintf('Locale "%s" not found in file %s', $locale, $this->_filename));
56 56
         }
@@ -58,7 +58,7 @@ protected function _loadTranslationData($data, $locale, array $options = array()
58 58
         // Rails YML files supported arbitrarily nested keys, Zend_Translate doesn't - so we flatten them.
59 59
         // See http://stackoverflow.com/questions/7011451/transaprently-flatten-an-array/7011675
60 60
         $flattened = array();
61  
-        if($content[$locale]) {
  61
+        if($content && $content[$locale]) {
62 62
             $iterator = new Translate_Adapter_RailsYaml_Iterator(new RecursiveArrayIterator($content[$locale]));
63 63
             foreach($iterator as $k => $v) {
64 64
                 $flattened[implode($options['keyDelimiter'], $iterator->getKeyStack())] = $v;

0 notes on commit ef5e639

Please sign in to comment.
Something went wrong with that request. Please try again.