fix server side translations

This commit is contained in:
fccview
2025-11-05 22:03:36 +00:00
parent b9fb009923
commit 11c96d0aed
4 changed files with 18 additions and 3 deletions

View File

@@ -4,3 +4,16 @@ import { twMerge } from "tailwind-merge"
export const cn = (...inputs: ClassValue[]) => {
return twMerge(clsx(inputs))
}
export async function getTranslations(locale: string = process.env.LOCALE || "en") {
const messages = (await import(`../_translations/${locale}.json`)).default;
return (key: string) => {
const keys = key.split('.');
let value: any = messages;
for (const k of keys) {
value = value?.[k];
}
return value || key;
};
}

View File

@@ -1,13 +1,14 @@
import { NextRequest, NextResponse } from 'next/server';
import * as si from 'systeminformation';
import { getTranslations } from '@/app/_utils/global-utils';
export const dynamic = 'force-dynamic';
import { getTranslations } from 'next-intl/server';
export async function GET(request: NextRequest) {
try {
const t = await getTranslations();
const [
memInfo,
cpuInfo,

View File

@@ -6,12 +6,13 @@ import { ThemeToggle } from "@/app/_components/FeatureComponents/Theme/ThemeTogg
import { LogoutButton } from "@/app/_components/FeatureComponents/LoginForm/LogoutButton";
import { ToastContainer } from "@/app/_components/GlobalComponents/UIElements/Toast";
import { PWAInstallPrompt } from "@/app/_components/FeatureComponents/PWA/PWAInstallPrompt";
import { getTranslations } from "next-intl/server";
import { getTranslations } from "@/app/_utils/global-utils";
export const dynamic = "force-dynamic";
export default async function Home() {
const t = await getTranslations();
const [cronJobs, scripts] = await Promise.all([
getCronJobs(),
fetchScripts(),

View File

@@ -1,6 +1,6 @@
{
"name": "cronjob-manager",
"version": "0.1.0",
"version": "1.5.0",
"private": true,
"scripts": {
"dev": "next dev",