ArrayLoader.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Illuminate\Translation;
  3. use Illuminate\Contracts\Translation\Loader;
  4. class ArrayLoader implements Loader
  5. {
  6. /**
  7. * All of the translation messages.
  8. *
  9. * @var array
  10. */
  11. protected $messages = [];
  12. /**
  13. * Load the messages for the given locale.
  14. *
  15. * @param string $locale
  16. * @param string $group
  17. * @param string|null $namespace
  18. * @return array
  19. */
  20. public function load($locale, $group, $namespace = null)
  21. {
  22. $namespace = $namespace ?: '*';
  23. return $this->messages[$namespace][$locale][$group] ?? [];
  24. }
  25. /**
  26. * Add a new namespace to the loader.
  27. *
  28. * @param string $namespace
  29. * @param string $hint
  30. * @return void
  31. */
  32. public function addNamespace($namespace, $hint)
  33. {
  34. //
  35. }
  36. /**
  37. * Add a new JSON path to the loader.
  38. *
  39. * @param string $path
  40. * @return void
  41. */
  42. public function addJsonPath($path)
  43. {
  44. //
  45. }
  46. /**
  47. * Add messages to the loader.
  48. *
  49. * @param string $locale
  50. * @param string $group
  51. * @param array $messages
  52. * @param string|null $namespace
  53. * @return $this
  54. */
  55. public function addMessages($locale, $group, array $messages, $namespace = null)
  56. {
  57. $namespace = $namespace ?: '*';
  58. $this->messages[$namespace][$locale][$group] = $messages;
  59. return $this;
  60. }
  61. /**
  62. * Get an array of all the registered namespaces.
  63. *
  64. * @return array
  65. */
  66. public function namespaces()
  67. {
  68. return [];
  69. }
  70. }