Skip to content

Commit

Permalink
MINOR Don't break on empty YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Apr 15, 2012
1 parent a452b6a commit ef5e639
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ protected function _loadTranslationData($data, $locale, array $options = array()
}

$content = sfYaml::load(file_get_contents($this->_filename));
if($locale != 'auto' && !array_key_exists($locale, $content)) {
if($locale != 'auto' && $content && !array_key_exists($locale, $content)) {
require_once 'Zend/Translate/Exception.php';
throw new Zend_Translate_Exception(sprintf('Locale "%s" not found in file %s', $locale, $this->_filename));
}

// Rails YML files supported arbitrarily nested keys, Zend_Translate doesn't - so we flatten them.
// See http://stackoverflow.com/questions/7011451/transaprently-flatten-an-array/7011675
$flattened = array();
if($content[$locale]) {
if($content && $content[$locale]) {
$iterator = new Translate_Adapter_RailsYaml_Iterator(new RecursiveArrayIterator($content[$locale]));
foreach($iterator as $k => $v) {
$flattened[implode($options['keyDelimiter'], $iterator->getKeyStack())] = $v;
Expand Down

0 comments on commit ef5e639

Please sign in to comment.