LocaleBundle.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /**
  12. * Default implementation of {@link LocaleBundleInterface}.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class LocaleBundle extends AbstractBundle implements LocaleBundleInterface
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function getLocaleName($ofLocale, $locale = null)
  22. {
  23. if (null === $locale) {
  24. $locale = \Locale::getDefault();
  25. }
  26. return $this->readEntry($locale, array('Locales', $ofLocale));
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getLocaleNames($locale = null)
  32. {
  33. if (null === $locale) {
  34. $locale = \Locale::getDefault();
  35. }
  36. if (null === ($locales = $this->readEntry($locale, array('Locales')))) {
  37. return array();
  38. }
  39. if ($locales instanceof \Traversable) {
  40. $locales = iterator_to_array($locales);
  41. }
  42. return $locales;
  43. }
  44. }