Skip to content

Commit

Permalink
added lang definition file requirement checker to the compiler extension
Browse files Browse the repository at this point in the history
  • Loading branch information
castamir committed Apr 15, 2013
1 parent 2d35491 commit 69a8941
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions GettextTranslator/DI/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public function loadConfiguration()
$translator->setClass('GettextTranslator\Gettext', array('@session', '@cacheStorage', '@httpResponse'));
$translator->addSetup('setLang', $config['lang']);
$translator->addSetup('setProductionMode', $builder->expand('%productionMode%'));

// at least one language file must be defined
if (count($config['files']) === 0) {
throw new InvalidConfigException('Language file(s) must be defined.');
}
foreach ($config['files'] as $id => $file) {
$translator->addSetup('addFile', $file, $id);
}
Expand All @@ -32,3 +37,7 @@ public function loadConfiguration()
}

}

class InvalidConfigException extends Nette\InvalidStateException {

}

0 comments on commit 69a8941

Please sign in to comment.