mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +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) {
|
||||
return new PageController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query(IL10N::class)
|
||||
$c->query('Request')
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue