diff --git a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php index 4b9e0df0d..0b040139c 100644 --- a/integrations/nextcloud/snappymail/lib/AppInfo/Application.php +++ b/integrations/nextcloud/snappymail/lib/AppInfo/Application.php @@ -35,8 +35,7 @@ class Application extends App implements IBootstrap 'PageController', function($c) { return new PageController( $c->query('AppName'), - $c->query('Request'), - $c->query(IL10N::class) + $c->query('Request') ); } ); diff --git a/integrations/nextcloud/snappymail/lib/Controller/PageController.php b/integrations/nextcloud/snappymail/lib/Controller/PageController.php index 1c001954e..7744cb4fc 100644 --- a/integrations/nextcloud/snappymail/lib/Controller/PageController.php +++ b/integrations/nextcloud/snappymail/lib/Controller/PageController.php @@ -7,24 +7,9 @@ use OCA\SnappyMail\ContentSecurityPolicy; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; -use OCP\IL10N; -use OCP\IRequest; class PageController extends Controller { -// private IL10N $l; - - public function __construct(string $appName, IRequest $request, IL10N $l) { - parent::__construct($appName, $request); -// $this->l = $l; - $lang = \strtolower(\str_replace('_', '-', $l->getLocaleCode())); - if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; - } else { - $_SERVER['HTTP_ACCEPT_LANGUAGE'] .= ",{$lang};q=2"; - } - } - /** * @NoAdminRequired * @NoCSRFRequired diff --git a/plugins/README.md b/plugins/README.md index 4395119da..e19e799a1 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -285,6 +285,13 @@ and called in JavaScript using rl.pluginRemoteRequest(). params: array &$aPaths +### filter.language + params: + string &$sLanguage + bool $bAdmin + + Allows you to set a different language + ### filter.message-html params: \RainLoop\Model\Account $oAccount diff --git a/plugins/nextcloud/index.php b/plugins/nextcloud/index.php index c2aa7522f..614c423ad 100644 --- a/plugins/nextcloud/index.php +++ b/plugins/nextcloud/index.php @@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin { const NAME = 'Nextcloud', - VERSION = '2.25', - RELEASE = '2023-10-03', + VERSION = '2.26', + RELEASE = '2023-12-08', CATEGORY = 'Integrations', DESCRIPTION = 'Integrate with Nextcloud v20+', REQUIRED = '2.27.0'; @@ -17,6 +17,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin $this->addHook('main.fabrica', 'MainFabrica'); $this->addHook('filter.app-data', 'FilterAppData'); + $this->addHook('filter.language', 'FilterLanguage'); $this->addCss('style.css'); @@ -244,6 +245,17 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin } } + public function FilterLanguage($bAdmin, &$sLanguage) : void + { + if (!\RainLoop\Api::Config()->Get('webmail', 'allow_languages_on_settings', true)) { + $sLanguage = \RainLoop\Api::Actions()->ValidateLanguage( + \OC::$server->getL10N('core')->getLocaleCode(), + $sLanguage, + $bAdmin + ); + } + } + /** * @param mixed $mResult */ diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php index 8230fb978..88d6ddb2d 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php @@ -23,7 +23,9 @@ trait Localization $sLanguage = $this->ValidateLanguage($this->detectUserLanguage($bAdmin), $sLanguage, false); } } - return $this->ValidateLanguage($sLanguage, '', $bAdmin) ?: 'en'; + $sHookLanguage = $sLanguage = $this->ValidateLanguage($sLanguage, '', $bAdmin) ?: 'en'; + $this->Plugins()->RunHook('filter.language', array(&$sHookLanguage, $bAdmin)); + return $this->ValidateLanguage($sHookLanguage, $sLanguage, $bAdmin); } public function ValidateLanguage(string $sLanguage, string $sDefault = '', bool $bAdmin = false, bool $bAllowEmptyResult = false): string