ITranslationManager.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Translation;
  8. use InvalidArgumentException;
  9. use OCP\PreConditionNotMetException;
  10. /**
  11. * @since 26.0.0
  12. */
  13. interface ITranslationManager {
  14. /**
  15. * @since 26.0.0
  16. */
  17. public function hasProviders(): bool;
  18. /**
  19. * @return ITranslationProvider[]
  20. * @since 27.1.0
  21. */
  22. public function getProviders(): array;
  23. /**
  24. * @since 26.0.0
  25. */
  26. public function canDetectLanguage(): bool;
  27. /**
  28. * @since 26.0.0
  29. * @return LanguageTuple[]
  30. */
  31. public function getLanguages(): array;
  32. /**
  33. * @since 26.0.0
  34. * @throws PreConditionNotMetException If no provider was registered but this method was still called
  35. * @throws InvalidArgumentException If no matching provider was found that can detect a language
  36. * @throws CouldNotTranslateException If the translation failed for other reasons
  37. */
  38. public function translate(string $text, ?string &$fromLanguage, string $toLanguage): string;
  39. }