From e3f33c4a553f3c2905796a2872413dbe210f64ac Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Fri, 5 Jan 2024 18:04:29 +0100 Subject: [PATCH] fix: translate popup does not open in mobile apps Signed-off-by: Luka Trovic --- lib/DirectEditing/TextDirectEditor.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/DirectEditing/TextDirectEditor.php b/lib/DirectEditing/TextDirectEditor.php index dfec634ac2d..d8622a7fa0a 100644 --- a/lib/DirectEditing/TextDirectEditor.php +++ b/lib/DirectEditing/TextDirectEditor.php @@ -35,6 +35,7 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IL10N; +use OCP\Translation\ITranslationManager; use OCP\Util; class TextDirectEditor implements IEditor { @@ -48,10 +49,14 @@ class TextDirectEditor implements IEditor { /** @var ApiService */ private $apiService; - public function __construct(IL10N $l10n, IInitialState $initialStateService, ApiService $apiService) { + /** @var ITranslationManager */ + private $translationManager; + + public function __construct(IL10N $l10n, IInitialState $initialStateService, ApiService $apiService, ITranslationManager $translationManager) { $this->l10n = $l10n; $this->initialStateService = $initialStateService; $this->apiService = $apiService; + $this->translationManager = $translationManager; } /** @@ -159,6 +164,14 @@ public function open(IToken $token): Response { 'session' => \json_encode($session->getData()) ]); $this->initialStateService->provideInitialState('directEditingToken', $token->getToken()); + $this->initialStateService->provideInitialState( + 'translation_can_detect', + $this->translationManager->canDetectLanguage() + ); + $this->initialStateService->provideInitialState( + 'translation_languages', + $this->translationManager->getLanguages() + ); Util::addScript('text', 'text-text'); return new TemplateResponse('text', 'main', [], 'base'); } catch (InvalidPathException $e) {