Skip to content
Permalink
Browse files

Don't ignore empty MO translation files

  • Loading branch information...
berarma committed Jul 31, 2017
1 parent 47d1d27 commit 02e8c3d01c5cdd46be67a8cc13238d3264011001
@@ -71,9 +71,7 @@ public function __invoke()
));
}
if (count($package->getMessages())) {
return $package;
}
return $package;
}
return new Package();
@@ -101,13 +101,12 @@ public function __construct($name, $locale, $extension = 'po')
* Loads the translation file and parses it. Returns an instance of a translations
* package containing the messages loaded from the file.
*
* @return \Aura\Intl\Package
* @return \Aura\Intl\Package|false
* @throws \RuntimeException if no file parser class could be found for the specified
* file extension.
*/
public function __invoke()
{
$package = new Package('default');
$folders = $this->translationsFolders();
$ext = $this->_extension;
$file = false;
@@ -126,7 +125,7 @@ public function __invoke()
}
if (!$file) {
return $package;
return false;
}
$name = ucfirst($ext);
@@ -137,6 +136,7 @@ public function __invoke()
}
$messages = (new $class)->parse($file);
$package = new Package('default');
$package->setMessages($messages);
return $package;
@@ -64,4 +64,19 @@ public function testCustomLocalePath()
$messages = $package->getMessages();
$this->assertEquals('Po (translated) from custom folder', $messages['Plural Rule 1']['_context']['']);
}
/**
* Test reading MO files
* @return void
*/
public function testLoadingMoFiles()
{
$loader = new MessagesFileLoader('empty', 'es', 'mo');
$package = $loader();
$this->assertNotFalse($package);
$loader = new MessagesFileLoader('missing', 'es', 'mo');
$package = $loader();
$this->assertFalse($package);
}
}
Binary file not shown.

0 comments on commit 02e8c3d

Please sign in to comment.
You can’t perform that action at this time.