Created
October 31, 2019 20:29
-
-
Save parzibyte/73c958852a98ad60827be4f8b1e9478d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once "vendor/autoload.php"; | |
use Symfony\Component\Translation\Loader\JsonFileLoader; | |
use Symfony\Component\Translation\Translator; | |
$idioma = "en"; | |
$traductor = new Translator($idioma); | |
$traductor->addLoader("json", new JsonFileLoader()); | |
$traductor->addResource("json", "idioma_es.json", "es"); | |
$traductor->addResource("json", "idioma_en.json", "en"); | |
$traductor->setFallbackLocales(["es"]); // Si no se encuentra el idioma, utilizamos es por defecto | |
$saludoTraducido = $traductor->trans("saludo"); | |
echo $saludoTraducido; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment