summaryrefslogtreecommitdiffstats
path: root/lib/private/Translation
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-05-01 15:14:18 +0200
committerJoas Schilling <coding@schilljs.com>2023-05-02 16:38:33 +0200
commit9d6ec68b593a62f4a17388464f8cae4ce23e8201 (patch)
tree6997ae010a21d06f504b6c73c55fd35df1e783ee /lib/private/Translation
parentdc67b48c28c37d77b29b9b9ed987d0664811eddf (diff)
downloadnextcloud-server-9d6ec68b593a62f4a17388464f8cae4ce23e8201.tar.gz
nextcloud-server-9d6ec68b593a62f4a17388464f8cae4ce23e8201.zip
feat(translation): Return the detected language so clients can show more details
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Translation')
-rw-r--r--lib/private/Translation/TranslationManager.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Translation/TranslationManager.php b/lib/private/Translation/TranslationManager.php
index 3fded754f6a..2a2b2cd0066 100644
--- a/lib/private/Translation/TranslationManager.php
+++ b/lib/private/Translation/TranslationManager.php
@@ -30,6 +30,7 @@ use InvalidArgumentException;
use OC\AppFramework\Bootstrap\Coordinator;
use OCP\IServerContainer;
use OCP\PreConditionNotMetException;
+use OCP\Translation\CouldNotTranslateException;
use OCP\Translation\IDetectLanguageProvider;
use OCP\Translation\ITranslationManager;
use OCP\Translation\ITranslationProvider;
@@ -58,7 +59,7 @@ class TranslationManager implements ITranslationManager {
return $languages;
}
- public function translate(string $text, ?string $fromLanguage, string $toLanguage): string {
+ public function translate(string $text, ?string &$fromLanguage, string $toLanguage): string {
if (!$this->hasProviders()) {
throw new PreConditionNotMetException('No translation providers available');
}
@@ -87,7 +88,7 @@ class TranslationManager implements ITranslationManager {
}
}
- throw new RuntimeException('Could not translate text');
+ throw new CouldNotTranslateException($fromLanguage);
}
public function getProviders(): array {