Some changes for #1293

This commit is contained in:
the-djmaze 2023-11-20 22:40:33 +01:00
parent 930be49775
commit 8247357184
3 changed files with 20 additions and 3 deletions

View file

@ -34,7 +34,8 @@ 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)
); );
} }
); );

View file

@ -12,8 +12,9 @@ use OCP\IL10N;
use OCP\IRequest; use OCP\IRequest;
class FetchController extends Controller { class FetchController extends Controller {
private $config; private IConfig $config;
private $appManager; private IAppManager $appManager;
private IL10N $l;
public function __construct(string $appName, IRequest $request, IAppManager $appManager, IConfig $config, IL10N $l) { public function __construct(string $appName, IRequest $request, IAppManager $appManager, IConfig $config, IL10N $l) {
parent::__construct($appName, $request); parent::__construct($appName, $request);

View file

@ -7,9 +7,24 @@ 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