TranslatorInterface.php 901 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Contract;
  12. use Countable;
  13. interface TranslatorInterface
  14. {
  15. /**
  16. * Get the translation for a given key.
  17. */
  18. public function trans(string $key, array $replace = [], ?string $locale = null): array|string;
  19. /**
  20. * Get a translation according to an integer value.
  21. *
  22. * @param array|Countable|int $number
  23. */
  24. public function transChoice(string $key, $number, array $replace = [], ?string $locale = null): string;
  25. /**
  26. * Get the default locale being used.
  27. */
  28. public function getLocale(): string;
  29. /**
  30. * Set the default locale.
  31. */
  32. public function setLocale(string $locale);
  33. }