mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat: add server default locale setting (#1536)
* feat: add server default locale setting * fix: do not modify defaultLocale property of IntlProvider
This commit is contained in:
@@ -32,6 +32,7 @@ export interface PublicSettingsResponse {
|
||||
cacheImages: boolean;
|
||||
vapidPublic: string;
|
||||
enablePushRegistration: boolean;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
export interface CacheItem {
|
||||
|
@@ -88,6 +88,7 @@ export interface MainSettings {
|
||||
originalLanguage: string;
|
||||
trustProxy: boolean;
|
||||
partialRequestsEnabled: boolean;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
interface PublicSettings {
|
||||
@@ -106,6 +107,7 @@ interface FullPublicSettings extends PublicSettings {
|
||||
cacheImages: boolean;
|
||||
vapidPublic: string;
|
||||
enablePushRegistration: boolean;
|
||||
locale: string;
|
||||
}
|
||||
|
||||
export interface NotificationAgentConfig {
|
||||
@@ -249,6 +251,7 @@ class Settings {
|
||||
originalLanguage: '',
|
||||
trustProxy: false,
|
||||
partialRequestsEnabled: true,
|
||||
locale: 'en',
|
||||
},
|
||||
plex: {
|
||||
name: '',
|
||||
@@ -411,6 +414,7 @@ class Settings {
|
||||
cacheImages: this.data.main.cacheImages,
|
||||
vapidPublic: this.vapidPublic,
|
||||
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
|
||||
locale: this.data.main.locale,
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import { getSettings } from '../lib/settings';
|
||||
|
||||
export const checkUser: Middleware = async (req, _res, next) => {
|
||||
const settings = getSettings();
|
||||
|
||||
if (req.header('X-API-Key') === settings.main.apiKey) {
|
||||
const userRepository = getRepository(User);
|
||||
|
||||
@@ -28,9 +29,12 @@ export const checkUser: Middleware = async (req, _res, next) => {
|
||||
|
||||
if (user) {
|
||||
req.user = user;
|
||||
req.locale = user.settings?.locale;
|
||||
req.locale = user.settings?.locale
|
||||
? user.settings?.locale
|
||||
: settings.main.locale;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user