Created
October 31, 2019 21:00
-
-
Save parzibyte/6177d8c76e7f588ed94d7cbd9466c837 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 = "es"; | |
$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("bienvenido", [ | |
"{usuario}" => "parzibyte", | |
]); | |
echo $saludoTraducido; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment