summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/Translation/CouldNotTranslateException.php47
-rw-r--r--lib/public/Translation/ITranslationManager.php5
2 files changed, 49 insertions, 3 deletions
diff --git a/lib/public/Translation/CouldNotTranslateException.php b/lib/public/Translation/CouldNotTranslateException.php
new file mode 100644
index 00000000000..bf7f5b4e8b3
--- /dev/null
+++ b/lib/public/Translation/CouldNotTranslateException.php
@@ -0,0 +1,47 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCP\Translation;
+
+/**
+ * @since 27.0.0
+ */
+class CouldNotTranslateException extends \RuntimeException {
+ /**
+ * @since 27.0.0
+ */
+ public function __construct(
+ protected ?string $from,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 27.0.0
+ */
+ public function getFrom(): ?string {
+ return $this->from;
+ }
+}
diff --git a/lib/public/Translation/ITranslationManager.php b/lib/public/Translation/ITranslationManager.php
index c6b67462152..4450f19c424 100644
--- a/lib/public/Translation/ITranslationManager.php
+++ b/lib/public/Translation/ITranslationManager.php
@@ -28,7 +28,6 @@ namespace OCP\Translation;
use InvalidArgumentException;
use OCP\PreConditionNotMetException;
-use RuntimeException;
/**
* @since 26.0.0
@@ -54,7 +53,7 @@ interface ITranslationManager {
* @since 26.0.0
* @throws PreConditionNotMetException If no provider was registered but this method was still called
* @throws InvalidArgumentException If no matching provider was found that can detect a language
- * @throws RuntimeException If the translation failed for other reasons
+ * @throws CouldNotTranslateException If the translation failed for other reasons
*/
- public function translate(string $text, ?string $fromLanguage, string $toLanguage): string;
+ public function translate(string $text, ?string &$fromLanguage, string $toLanguage): string;
}