bug #13953 [Translation][MoFileLoader] fixed load empty translation. (aitboudad)
This PR was merged into the 2.3 branch.
Discussion
----------
[Translation][MoFileLoader] fixed load empty translation.
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Fixed tickets | #13547
| Tests pass? | yes
| License | MIT
see https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
![selection_003](https://cloud.githubusercontent.com/assets/1753742/6690874/fcf04ef6-ccba-11e4-83a4-4f50188709c5.png)
Commits
-------
22f5a73
[Translation][MoFileLoader] fixed load empty translation.
This commit is contained in:
commit
bd0eaef28d
|
@ -137,6 +137,10 @@ class MoFileLoader extends ArrayLoader implements LoaderInterface
|
|||
$length = $this->readLong($stream, $isBigEndian);
|
||||
$offset = $this->readLong($stream, $isBigEndian);
|
||||
|
||||
if ($length < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fseek($stream, $offset);
|
||||
$translated = fread($stream, $length);
|
||||
|
||||
|
|
|
@ -57,4 +57,15 @@ class MoFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
$resource = __DIR__.'/../fixtures/empty.mo';
|
||||
$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());
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Reference in New Issue