To get support for XLIFF / 2 in PHP, in another answer , it was suggested to use the Symfony 2 translation component.
So I downloaded it from Github to a directory ../vendor/and naively tried using it:
<?php
require_once '../vendor/Symfony/Component/Translation/Translator.php';
require_once '../vendor/Symfony/Component/Translation/MessageSelector.php';
require_once '../vendor/Symfony/Component/Translation/Loader/ArrayLoader.php';
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\ArrayLoader;
$translator = new Translator('fr_FR', new MessageSelector());
This does not work as other components need to be loaded:
PHP Fatal error: Interface 'Symfony\\Component\\Translation\\TranslatorInterface' not found in /home/ec2-user/layout/vendor/Symfony/Component/Translation/Translator.php on line 25
Now I can manually add require_oncefor each file until all the dependencies, but I'm not sure if this is the right approach.
How to use one Symfony 2 component in a project other than Symfony? It is a bad idea?
source
share