merged branch clemens-tolboom/pofileloader-emptytranslations (PR #4337)
Commits -------dd60166
Fixed for allowing empty translation. Discussion ---------- Fixed for allowing empty translation. PoFileLoader should accept empty translations. PoFileLoader calls array_filter just before returning the $messages thus filtering empty translations. For Drupal we need to be able to load and then translate incomplete PO and POT files. (this is part of [[WIP]: Allow Drupal to use Translate component](https://github.com/symfony/symfony/pull/4249)) --------------------------------------------------------------------------- by travisbot at 2012-05-19T11:14:39Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1373933) (merged 5ee0b1e6 into58b92453
). --------------------------------------------------------------------------- by travisbot at 2012-05-19T12:09:48Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374129) (mergeddd601662
into58b92453
).
This commit is contained in:
commit
af41cc7096
@ -105,6 +105,6 @@ class PoFileLoader extends ArrayLoader implements LoaderInterface
|
|||||||
}
|
}
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
|
|
||||||
return array_filter($messages);
|
return $messages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,4 +54,15 @@ class PoFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('en', $catalogue->getLocale());
|
$this->assertEquals('en', $catalogue->getLocale());
|
||||||
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoadEmptyTranslation()
|
||||||
|
{
|
||||||
|
$loader = new PoFileLoader();
|
||||||
|
$resource = __DIR__.'/../fixtures/empty-translation.po';
|
||||||
|
$catalogue = $loader->load($resource, 'en', 'domain1');
|
||||||
|
|
||||||
|
$this->assertEquals(array('foo' => ''), $catalogue->all('domain1'));
|
||||||
|
$this->assertEquals('en', $catalogue->getLocale());
|
||||||
|
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
3
src/Symfony/Component/Translation/Tests/fixtures/empty-translation.po
vendored
Normal file
3
src/Symfony/Component/Translation/Tests/fixtures/empty-translation.po
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
msgid "foo"
|
||||||
|
msgstr ""
|
||||||
|
|
Reference in New Issue
Block a user