[Translation][MoFileLoader] fixed load empty translation.
This commit is contained in:
parent
a68f09e630
commit
22f5a735fd
@ -137,6 +137,10 @@ class MoFileLoader extends ArrayLoader implements LoaderInterface
|
|||||||
$length = $this->readLong($stream, $isBigEndian);
|
$length = $this->readLong($stream, $isBigEndian);
|
||||||
$offset = $this->readLong($stream, $isBigEndian);
|
$offset = $this->readLong($stream, $isBigEndian);
|
||||||
|
|
||||||
|
if ($length < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
fseek($stream, $offset);
|
fseek($stream, $offset);
|
||||||
$translated = fread($stream, $length);
|
$translated = fread($stream, $length);
|
||||||
|
|
||||||
|
@ -57,4 +57,15 @@ class MoFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$resource = __DIR__.'/../fixtures/empty.mo';
|
$resource = __DIR__.'/../fixtures/empty.mo';
|
||||||
$loader->load($resource, 'en', 'domain1');
|
$loader->load($resource, 'en', 'domain1');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoadEmptyTranslation()
|
||||||
|
{
|
||||||
|
$loader = new MoFileLoader();
|
||||||
|
$resource = __DIR__.'/../fixtures/empty-translation.mo';
|
||||||
|
$catalogue = $loader->load($resource, 'en', 'message');
|
||||||
|
|
||||||
|
$this->assertEquals(array(), $catalogue->all('message'));
|
||||||
|
$this->assertEquals('en', $catalogue->getLocale());
|
||||||
|
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/Symfony/Component/Translation/Tests/fixtures/empty-translation.mo
vendored
Normal file
BIN
src/Symfony/Component/Translation/Tests/fixtures/empty-translation.mo
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user