Skip to content

Commit

Permalink
fix: translate popup does not open in mobile apps
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Jan 5, 2024
1 parent a6e404c commit e3f33c4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/DirectEditing/TextDirectEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e3f33c4

Please sign in to comment.