Skip to content

Commit

Permalink
minor #17903 Validate XLIFF translation files (javiereguiluz)
Browse files Browse the repository at this point in the history
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
fabpot committed Feb 23, 2016
2 parents 5f08b45 + db03055 commit 0807ff7
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
@@ -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')
);
}
}
@@ -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')
);
}
}
@@ -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')
);
}
}

0 comments on commit 0807ff7

Please sign in to comment.