LocaleBundle.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\ResourceBundle;
  11. use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
  12. use Symfony\Component\Intl\Exception\MissingResourceException;
  13. /**
  14. * Default implementation of {@link LocaleBundleInterface}.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. *
  18. * @internal
  19. */
  20. class LocaleBundle extends LocaleDataProvider implements LocaleBundleInterface
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function getLocales()
  26. {
  27. try {
  28. return parent::getLocales();
  29. } catch (MissingResourceException $e) {
  30. return array();
  31. }
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getLocaleName($locale, $displayLocale = null)
  37. {
  38. try {
  39. return $this->getName($locale, $displayLocale);
  40. } catch (MissingResourceException $e) {
  41. return;
  42. }
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getLocaleNames($displayLocale = null)
  48. {
  49. try {
  50. return $this->getNames($displayLocale);
  51. } catch (MissingResourceException $e) {
  52. return array();
  53. }
  54. }
  55. }