Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. <<<CONFIG
  3. packages:
  4. - "twig/twig: ^2"
  5. - "twig/intl-extra: 3.x-dev"
  6. - "symfony/var-dumper: ^4"
  7. CONFIG;
  8.  
  9. $loader = new \Twig\Loader\ArrayLoader([
  10. 'ok_fr' => "{{ 'fr'|language_name }}\n",
  11. 'ok_fr_CA' => "{{ 'fr_CA'|language_name }}\n",
  12. 'ko_fr_FR' => "{{ 'fr_FR'|language_name }}\n",
  13. ]);
  14. $twig = new \Twig\Environment($loader);
  15. $twig->addExtension(new \Twig\Extra\Intl\IntlExtension());
  16.  
  17. echo $twig->render('ok_fr'); // French
  18. echo $twig->render('ok_fr_CA'); // Canadian French
  19.  
  20. try {
  21. echo $twig->render('ko_fr_FR');
  22. } catch (\Exception $e) {
  23. dump($e);
  24. }
  25. /*
  26. Twig\Error\RuntimeError^ {#159
  27. -lineno: 1
  28. -name: "ko_fr_FR"
  29. -rawMessage: "An exception has been thrown during the rendering of a template ("Couldn't read the indices [Names][fr_FR] for the locale "en_US" in "/path/vendor/symfony/intl/Resources/data/languages". The indices also couldn't be found for the fallback locale(s) "en", "root".")."
  30. -sourcePath: ""
  31. -sourceCode: ""
  32. #message: "An exception has been thrown during the rendering of a template ("Couldn't read the indices [Names][fr_FR] for the locale "en_US" in "/path/vendor/symfony/intl/Resources/data/languages". The indices also couldn't be found for the fallback locale(s) "en", "root".") in "ko_fr_FR" at line 1."
  33. #code: 0
  34. #file: "/path/vendor/twig/twig/src/Template.php"
  35. #line: 421
  36. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement