Created
May 22, 2017 18:50
-
-
Save Pawka/fccecce2a6fff812c7572cdfeaa65dfa to your computer and use it in GitHub Desktop.
Check if translation exists with Symfony translation component
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 | |
require 'vendor/autoload.php'; | |
use Symfony\Component\Translation\Translator; | |
use Symfony\Component\Translation\MessageSelector; | |
use Symfony\Component\Translation\Loader\ArrayLoader; | |
/** | |
* Class run | |
* @author yourname | |
*/ | |
class Core | |
{ | |
public function run() | |
{ | |
$locale = 'fr_FR'; | |
$locale = 'lt_LT'; | |
$translator = new Translator($locale, new MessageSelector()); | |
$translator->addLoader('array', new ArrayLoader()); | |
$translator->addResource('array', array( | |
'Hello World!' => 'Bonjour', | |
), 'fr_FR'); | |
$translator->addResource('array', array( | |
'Hello World!' => 'Labas!', | |
'Crab' => 'Krabas', | |
), 'lt_LT'); | |
echo "RUNNING....\n"; | |
echo $translator->trans('Crab') . PHP_EOL; | |
echo $translator->trans('Hello') . PHP_EOL; | |
$c = $translator->getCatalogue($locale); | |
var_dump($c->has('Crab')); die(); | |
} | |
} | |
$c = new Core(); | |
$c->run($argv, $argc); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment