for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the PHP Translation package.
*
* (c) PHP Translation team <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Translation\SymfonyStorage;
use Symfony\Component\Translation\MessageCatalogue;
use Translation\SymfonyStorage\Dumper\XliffDumper;
use Translation\SymfonyStorage\Loader\XliffLoader;
/**
* Utility class to convert between a MessageCatalogue and XLIFF file content.
* @author Tobias Nyholm <[email protected]>
final class XliffConverter
{
* Create a catalogue from the contents of a XLIFF file.
* @param string $content
* @param string $locale
* @param string $domain
* @return MessageCatalogue
public static function contentToCatalogue($content, $locale, $domain)
$loader = new XliffLoader();
$catalogue = new MessageCatalogue($locale);
$loader->extractFromContent($content, $catalogue, $domain);
return $catalogue;
}
* @param MessageCatalogue $catalogue
* @return string
public static function catalogueToContent(MessageCatalogue $catalogue, $domain)
$dumper = new XliffDumper();
return $dumper->getFormattedCatalogue($catalogue, $domain);