How can the Symfony translation component be integrated into a PHP application for language localization without using the full Symfony framework?

The Symfony translation component can be integrated into a PHP application for language localization without using the full Symfony framework by including only the necessary classes and components from the Symfony Translation component. This can be achieved by installing the Symfony Translation component via Composer and then using its classes and functions in your PHP application.

// Include Composer's autoloader
require_once 'vendor/autoload.php';

use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\ArrayLoader;

// Create a Translator instance
$translator = new Translator('en');

// Set up the loader
$translator->addLoader('array', new ArrayLoader());

// Load translations
$translator->addResource('array', [
    'Hello World!' => 'Bonjour le monde!',
], 'fr');

// Translate a message
echo $translator->trans('Hello World!'); // Output: Bonjour le monde!