mirror of
https://github.com/fccview/cronmaster.git
synced 2025-12-23 22:18:20 -05:00
fix server side translations
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cronjob-manager",
|
||||
"version": "0.1.0",
|
||||
"version": "1.5.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
Reference in New Issue
Block a user