Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #17903 Validate XLIFF translation files (javiereguiluz)
This PR was squashed before being merged into the 2.3 branch (closes #17903). Discussion ---------- Validate XLIFF translation files | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - In #17902 @stof proposed to add a simple test to validate `.xlf` files (to avoid issues like #17893). This is a proposal for that test. My questions: **1)** Do you agree displaying detailed error messages when the XML is not valid. Example output for the #17893 error: ![error_log](https://cloud.githubusercontent.com/assets/73419/13250664/932d2f14-da2b-11e5-8ea0-ecb43f58feea.png) Or is it enough displaying just the PHPUnit error message and let the user figure out the details? ![simple_error](https://cloud.githubusercontent.com/assets/73419/13250671/a3b4bfd2-da2b-11e5-9277-454d0dd160b2.png) **2)** How do I validate the translation files of the Security and Form components? Do I just copy+paste this test in those components? Commits ------- db03055 Validate XLIFF translation files
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Form\Tests\Resources; | ||
|
||
class TranslationFilesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider provideTranslationFiles | ||
*/ | ||
public function testTranslationFileIsValid($filePath) | ||
{ | ||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true); | ||
} | ||
|
||
public function provideTranslationFiles() | ||
{ | ||
return array_map( | ||
function ($filePath) { return (array) $filePath; }, | ||
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf') | ||
); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Symfony/Component/Security/Tests/Resources/TranslationFilesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Tests\Resources; | ||
|
||
class TranslationFilesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider provideTranslationFiles | ||
*/ | ||
public function testTranslationFileIsValid($filePath) | ||
{ | ||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true); | ||
} | ||
|
||
public function provideTranslationFiles() | ||
{ | ||
return array_map( | ||
function ($filePath) { return (array) $filePath; }, | ||
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf') | ||
); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Validator\Tests\Resources; | ||
|
||
class TranslationFilesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider provideTranslationFiles | ||
*/ | ||
public function testTranslationFileIsValid($filePath) | ||
{ | ||
\PHPUnit_Util_XML::loadfile($filePath, false, false, true); | ||
} | ||
|
||
public function provideTranslationFiles() | ||
{ | ||
return array_map( | ||
function ($filePath) { return (array) $filePath; }, | ||
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf') | ||
); | ||
} | ||
} |