mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 17:24:07 +00:00
Locales: use http-accept-language or cookie (#976)
* Locales: use http-accept-language or "language"-cookie * Add user-setting "locale" Rename CULTURE to DEFAULT_LOCALE * Use LocaleMiddleware also in dev mode * CORS: don't require authentication on OPTIONS * Use a standard user-settings-control and start a new generic user settings page, not a separate page for the locale setting * Fixed (broken by myself) link-return handling * Clarify language settings * Removed unneeded files * Better user settings icon * Added localization hints Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
committed by
GitHub
parent
4a030b7ffc
commit
6f8ad9b76e
12
app.php
12
app.php
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Grocy\Middleware\CorsMiddleware;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Container\ContainerInterface as Container;
|
||||
@@ -63,6 +64,16 @@ if (!empty(GROCY_BASE_PATH))
|
||||
$app->setBasePath(GROCY_BASE_PATH);
|
||||
}
|
||||
|
||||
if (GROCY_MODE === 'production' || GROCY_MODE === 'dev')
|
||||
{
|
||||
$app->add(new \Grocy\Middleware\LocaleMiddleware($container));
|
||||
}
|
||||
else {
|
||||
define('GROCY_LOCALE', GROCY_DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
$authMiddlewareClass = GROCY_AUTH_CLASS;
|
||||
$app->add(new $authMiddlewareClass($container, $app->getResponseFactory()));
|
||||
// Add default middleware
|
||||
$app->addRoutingMiddleware();
|
||||
$errorMiddleware = $app->addErrorMiddleware(true, false, false);
|
||||
@@ -70,4 +81,5 @@ $errorMiddleware->setDefaultErrorHandler(
|
||||
new \Grocy\Controllers\ExceptionController($app, $container)
|
||||
);
|
||||
|
||||
$app->add(new CorsMiddleware($app->getResponseFactory()));
|
||||
$app->run();
|
||||
|
Reference in New Issue
Block a user