For getting XLIFF/2 support in PHP, in another answer, it was suggested to use the Symfony 2 Translation component.
So I downloaded it from Github into a directory ../vendor/
and naively
tried to use 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 doesn’t work as other components would 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 could manually add a require_once
for every file, until all
dependencies are met, but I’m not sure if that’s the proper approach.
How do I use a single Symfony 2 component in a non-Symfony project? Is that a bad idea?