mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-18 16:07:10 +00:00
Language selection
This commit is contained in:
parent
5adb7b3967
commit
502f749151
@ -82,7 +82,7 @@ export default function Settings() {
|
|||||||
const [pushoverUrl, setPushoverUrl] = useState<string>("")
|
const [pushoverUrl, setPushoverUrl] = useState<string>("")
|
||||||
const [pushoverToken, setPushoverToken] = useState<string>("")
|
const [pushoverToken, setPushoverToken] = useState<string>("")
|
||||||
const [pushoverUser, setPushoverUser] = useState<string>("")
|
const [pushoverUser, setPushoverUser] = useState<string>("")
|
||||||
|
const [language, setLanguage] = useState<string>("english")
|
||||||
const [notifications, setNotifications] = useState<any[]>([])
|
const [notifications, setNotifications] = useState<any[]>([])
|
||||||
|
|
||||||
const [notificationTextApplication, setNotificationTextApplication] = useState<string>("")
|
const [notificationTextApplication, setNotificationTextApplication] = useState<string>("")
|
||||||
@ -271,6 +271,26 @@ export default function Settings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const language = Cookies.get("language")
|
||||||
|
if (language === "en") {
|
||||||
|
setLanguage("english")
|
||||||
|
} else if (language === "de") {
|
||||||
|
setLanguage("german")
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const setLanguageFunc = (value: string) => {
|
||||||
|
setLanguage(value)
|
||||||
|
if (value === "english") {
|
||||||
|
Cookies.set("language", "en")
|
||||||
|
} else if (value === "german") {
|
||||||
|
Cookies.set("language", "de")
|
||||||
|
}
|
||||||
|
// Reload the page
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
<AppSidebar />
|
<AppSidebar />
|
||||||
@ -424,6 +444,34 @@ export default function Settings() {
|
|||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Card className="overflow-hidden border-2 border-muted/20 shadow-sm">
|
||||||
|
<CardHeader className="bg-muted/10 px-6 py-4 border-b">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Palette className="h-5 w-5 text-primary" />
|
||||||
|
<h2 className="text-xl font-semibold">{t('Settings.LanguageSettings.Title')}</h2>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="pb-6">
|
||||||
|
<div className="text-sm text-muted-foreground mb-6">
|
||||||
|
{t('Settings.LanguageSettings.Description')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="max-w-md">
|
||||||
|
<Select value={language} onValueChange={(value: string) => setLanguageFunc(value)}>
|
||||||
|
<SelectTrigger className="w-full h-11">
|
||||||
|
<SelectValue>
|
||||||
|
{t(`Settings.LanguageSettings.${(language ?? "english").charAt(0).toUpperCase() + (language ?? "english").slice(1)}`)}
|
||||||
|
</SelectValue>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="english">{t('Settings.LanguageSettings.English')}</SelectItem>
|
||||||
|
<SelectItem value="german">{t('Settings.LanguageSettings.German')}</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
<Card className="overflow-hidden border-2 border-muted/20 shadow-sm">
|
<Card className="overflow-hidden border-2 border-muted/20 shadow-sm">
|
||||||
<CardHeader className="bg-muted/10 px-6 py-4 border-b">
|
<CardHeader className="bg-muted/10 px-6 py-4 border-b">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import "./globals.css";
|
|||||||
import { ThemeProvider } from "@/components/theme-provider"
|
import { ThemeProvider } from "@/components/theme-provider"
|
||||||
import {NextIntlClientProvider} from 'next-intl';
|
import {NextIntlClientProvider} from 'next-intl';
|
||||||
import {getLocale} from 'next-intl/server';
|
import {getLocale} from 'next-intl/server';
|
||||||
|
import {cookies} from 'next/headers';
|
||||||
|
|
||||||
const geistSans = Geist({
|
const geistSans = Geist({
|
||||||
variable: "--font-geist-sans",
|
variable: "--font-geist-sans",
|
||||||
@ -20,13 +21,17 @@ export const metadata: Metadata = {
|
|||||||
description: "The only Dashboard you will need for your Services",
|
description: "The only Dashboard you will need for your Services",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
|
const cookieStore = await cookies();
|
||||||
|
const locale = cookieStore.get('language')?.value || 'en';
|
||||||
|
const messages = (await import(`@/i18n/languages/${locale}.json`)).default;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang={locale}>
|
||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
>
|
>
|
||||||
@ -36,7 +41,7 @@ export default function RootLayout({
|
|||||||
enableSystem
|
enableSystem
|
||||||
disableTransitionOnChange
|
disableTransitionOnChange
|
||||||
>
|
>
|
||||||
<NextIntlClientProvider>
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||||
{children}
|
{children}
|
||||||
</NextIntlClientProvider>
|
</NextIntlClientProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
"noData": "Keine Daten",
|
"noData": "Keine Daten",
|
||||||
"Loading": "Lade...",
|
"Loading": "Lade...",
|
||||||
"Refresh": "Aktualisieren",
|
"Refresh": "Aktualisieren",
|
||||||
|
"Save": "Speichern",
|
||||||
"Server": {
|
"Server": {
|
||||||
"CPU": "CPU",
|
"CPU": "CPU",
|
||||||
"GPU": "GPU",
|
"GPU": "GPU",
|
||||||
@ -330,6 +331,12 @@
|
|||||||
"Dark": "Dunkel",
|
"Dark": "Dunkel",
|
||||||
"System": "System"
|
"System": "System"
|
||||||
},
|
},
|
||||||
|
"LanguageSettings": {
|
||||||
|
"Title": "Spracheinstellungen",
|
||||||
|
"Description": "Wählen Sie eine Sprache für die Anwendung.",
|
||||||
|
"English": "Englisch",
|
||||||
|
"German": "Deutsch"
|
||||||
|
},
|
||||||
"Notifications": {
|
"Notifications": {
|
||||||
"Title": "Benachrichtigungen",
|
"Title": "Benachrichtigungen",
|
||||||
"Description": "Erhalten Sie Warnungen bei Statusänderungen",
|
"Description": "Erhalten Sie Warnungen bei Statusänderungen",
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
"noData": "No data",
|
"noData": "No data",
|
||||||
"Loading": "Loading...",
|
"Loading": "Loading...",
|
||||||
"Refresh": "Refresh",
|
"Refresh": "Refresh",
|
||||||
|
"Save": "Save",
|
||||||
"Server": {
|
"Server": {
|
||||||
"CPU": "CPU",
|
"CPU": "CPU",
|
||||||
"GPU": "GPU",
|
"GPU": "GPU",
|
||||||
@ -330,6 +331,12 @@
|
|||||||
"Dark": "Dark",
|
"Dark": "Dark",
|
||||||
"System": "System"
|
"System": "System"
|
||||||
},
|
},
|
||||||
|
"LanguageSettings": {
|
||||||
|
"Title": "Language Settings",
|
||||||
|
"Description": "Select a language for the application.",
|
||||||
|
"English": "English",
|
||||||
|
"German": "German"
|
||||||
|
},
|
||||||
"Notifications": {
|
"Notifications": {
|
||||||
"Title": "Notifications",
|
"Title": "Notifications",
|
||||||
"Description": "Set up notifications to get instantly alerted when an application changes status.",
|
"Description": "Set up notifications to get instantly alerted when an application changes status.",
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import {getRequestConfig} from 'next-intl/server';
|
import {getRequestConfig} from 'next-intl/server';
|
||||||
|
import {cookies} from 'next/headers';
|
||||||
|
|
||||||
export default getRequestConfig(async () => {
|
export default getRequestConfig(async () => {
|
||||||
// Provide a static locale, fetch a user setting,
|
const cookieStore = await cookies();
|
||||||
// read from `cookies()`, `headers()`, etc.
|
const locale = cookieStore.get('language')?.value || 'en';
|
||||||
const locale = 'en';
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
locale,
|
locale,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user