mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Different solution to use Nextcloud languages #1293
This commit is contained in:
parent
8984726fd7
commit
e56415aa51
5 changed files with 25 additions and 20 deletions
|
|
@ -35,8 +35,7 @@ class Application extends App implements IBootstrap
|
||||||
'PageController', function($c) {
|
'PageController', function($c) {
|
||||||
return new PageController(
|
return new PageController(
|
||||||
$c->query('AppName'),
|
$c->query('AppName'),
|
||||||
$c->query('Request'),
|
$c->query('Request')
|
||||||
$c->query(IL10N::class)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -7,24 +7,9 @@ use OCA\SnappyMail\ContentSecurityPolicy;
|
||||||
|
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\IL10N;
|
|
||||||
use OCP\IRequest;
|
|
||||||
|
|
||||||
class PageController extends Controller
|
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
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,13 @@ and called in JavaScript using rl.pluginRemoteRequest().
|
||||||
params:
|
params:
|
||||||
array &$aPaths
|
array &$aPaths
|
||||||
|
|
||||||
|
### filter.language
|
||||||
|
params:
|
||||||
|
string &$sLanguage
|
||||||
|
bool $bAdmin
|
||||||
|
|
||||||
|
Allows you to set a different language
|
||||||
|
|
||||||
### filter.message-html
|
### filter.message-html
|
||||||
params:
|
params:
|
||||||
\RainLoop\Model\Account $oAccount
|
\RainLoop\Model\Account $oAccount
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Nextcloud',
|
NAME = 'Nextcloud',
|
||||||
VERSION = '2.25',
|
VERSION = '2.26',
|
||||||
RELEASE = '2023-10-03',
|
RELEASE = '2023-12-08',
|
||||||
CATEGORY = 'Integrations',
|
CATEGORY = 'Integrations',
|
||||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||||
REQUIRED = '2.27.0';
|
REQUIRED = '2.27.0';
|
||||||
|
|
@ -17,6 +17,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
$this->addHook('main.fabrica', 'MainFabrica');
|
$this->addHook('main.fabrica', 'MainFabrica');
|
||||||
$this->addHook('filter.app-data', 'FilterAppData');
|
$this->addHook('filter.app-data', 'FilterAppData');
|
||||||
|
$this->addHook('filter.language', 'FilterLanguage');
|
||||||
|
|
||||||
$this->addCss('style.css');
|
$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
|
* @param mixed $mResult
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ trait Localization
|
||||||
$sLanguage = $this->ValidateLanguage($this->detectUserLanguage($bAdmin), $sLanguage, false);
|
$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
|
public function ValidateLanguage(string $sLanguage, string $sDefault = '', bool $bAdmin = false, bool $bAllowEmptyResult = false): string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue