Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0807ff7

Browse filesBrowse files
committed
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
2 parents 5f08b45 + db03055 commit 0807ff7
Copy full SHA for 0807ff7

File tree

Expand file treeCollapse file tree

3 files changed

+93
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+93
-0
lines changed
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Resources;
13+
14+
class TranslationFilesTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @dataProvider provideTranslationFiles
18+
*/
19+
public function testTranslationFileIsValid($filePath)
20+
{
21+
\PHPUnit_Util_XML::loadfile($filePath, false, false, true);
22+
}
23+
24+
public function provideTranslationFiles()
25+
{
26+
return array_map(
27+
function ($filePath) { return (array) $filePath; },
28+
glob(dirname(dirname(__DIR__)).'/Resources/translations/*.xlf')
29+
);
30+
}
31+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.