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 into 58b92453).

---------------------------------------------------------------------------

by travisbot at 2012-05-19T12:09:48Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1374129) (merged dd601662 into 58b92453).
This commit is contained in:
Fabien Potencier 2012-05-19 15:16:40 +02:00
commit af41cc7096
3 changed files with 15 additions and 1 deletions

View File

@ -105,6 +105,6 @@ class PoFileLoader extends ArrayLoader implements LoaderInterface
}
fclose($stream);
return array_filter($messages);
return $messages;
}
}

View File

@ -54,4 +54,15 @@ class PoFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('en', $catalogue->getLocale());
$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());
}
}

View File

@ -0,0 +1,3 @@
msgid "foo"
msgstr ""