diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts
index 1accb3cd59..d625bc06a6 100644
--- a/apps/web/src/middleware.ts
+++ b/apps/web/src/middleware.ts
@@ -1,12 +1,19 @@
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { authMiddleware, redirectToSignIn } from "@clerk/nextjs";
+import { createI18nMiddleware } from 'next-international/middleware'
import { db, eq } from "@openstatus/db";
import { user, usersToWorkspaces, workspace } from "@openstatus/db/src/schema";
import { env } from "./env";
+const I18nMiddleware = createI18nMiddleware({
+ locales: ['en', 'es', 'fr', 'de'],
+ defaultLocale: 'en',
+ urlMappingStrategy: 'rewriteDefault'
+})
+
const before = (req: NextRequest) => {
const url = req.nextUrl.clone();
@@ -78,6 +85,13 @@ export default authMiddleware({
beforeAuth: before,
debug: false,
async afterAuth(auth, req) {
+
+ const host = req.headers.get("host");
+ const subdomain = getValidSubdomain(host);
+ if (subdomain || req.nextUrl.pathname.includes('/status-page/')) {
+ return I18nMiddleware(req)
+ }
+
// handle users who aren't authenticated
if (!auth.userId && !auth.isPublicRoute) {
return redirectToSignIn({ returnBackUrl: req.url });
@@ -164,4 +178,4 @@ export const config = {
"/(api/webhook|api/trpc)(.*)",
"/(!api/checker/:path*|!api/og|!api/ping)",
],
-};
+};
\ No newline at end of file
diff --git a/apps/web/src/yuzu/client.ts b/apps/web/src/yuzu/client.ts
new file mode 100644
index 0000000000..0509b0fd46
--- /dev/null
+++ b/apps/web/src/yuzu/client.ts
@@ -0,0 +1,10 @@
+'use client'
+
+import { createI18nClient } from 'next-international/client'
+
+export const { useCurrentLocale, useChangeLocale, useI18n, useScopedI18n, I18nProviderClient } = createI18nClient({
+ 'en': () => import('./en.json'),
+ 'es': () => import('./es.json'),
+ 'fr': () => import('./fr.json'),
+ 'de': () => import('./de.json')
+})
\ No newline at end of file
diff --git a/apps/web/src/yuzu/de.json b/apps/web/src/yuzu/de.json
new file mode 100644
index 0000000000..eac609d09d
--- /dev/null
+++ b/apps/web/src/yuzu/de.json
@@ -0,0 +1 @@
+{"Status":"Status","Incidents":"Vorfälle","powered by":"angetrieben von","The":"Die","status page":"Statusseite","uptime":"Betriebszeit","Something went wrong":"Etwas ist schief gelaufen","All incidents":"Alle Vorfälle","Latest incidents":"Letzte Vorfälle","Affected Monitors":"Betroffene Monitore","Latest Updates":"Letzte Updates","No incidents.":"Keine Vorfälle.","No incidents in the last week.":"Keine Vorfälle in der letzten Woche."}
\ No newline at end of file
diff --git a/apps/web/src/yuzu/en.json b/apps/web/src/yuzu/en.json
new file mode 100644
index 0000000000..266e351803
--- /dev/null
+++ b/apps/web/src/yuzu/en.json
@@ -0,0 +1 @@
+{"Status":"Status","Incidents":"Incidents","powered by":"powered by","The":"The","status page":"status page","uptime":"uptime","Something went wrong":"Something went wrong","All incidents":"All incidents","Latest incidents":"Latest incidents","Affected Monitors":"Affected Monitors","Latest Updates":"Latest Updates","No incidents.":"No incidents.","No incidents in the last week.":"No incidents in the last week."}
\ No newline at end of file
diff --git a/apps/web/src/yuzu/es.json b/apps/web/src/yuzu/es.json
new file mode 100644
index 0000000000..103d32d670
--- /dev/null
+++ b/apps/web/src/yuzu/es.json
@@ -0,0 +1 @@
+{"Status":"Estado","Incidents":"Incidentes","powered by":"accionado por","The":"La","status page":"página de estado","uptime":"tiempo de actividad","Something went wrong":"Algo salió mal","All incidents":"Todos los incidentes","Latest incidents":"Últimos incidentes","Affected Monitors":"Monitores afectados","Latest Updates":"Últimas actualizaciones","No incidents.":"Ningún incidente.","No incidents in the last week.":"Ningún incidente en la última semana."}
\ No newline at end of file
diff --git a/apps/web/src/yuzu/fr.json b/apps/web/src/yuzu/fr.json
new file mode 100644
index 0000000000..f707c2ce1b
--- /dev/null
+++ b/apps/web/src/yuzu/fr.json
@@ -0,0 +1 @@
+{"Status":"Statut","Incidents":"Incidents","powered by":"alimenté par","The":"La","status page":"page d'état","uptime":"temps de fonctionnement","Something went wrong":"Quelque chose n'a pas fonctionné","All incidents":"Tous les incidents","Latest incidents":"Derniers incidents","Affected Monitors":"Moniteurs concernés","Latest Updates":"Dernières mises à jour","No incidents.":"Aucun incident.","No incidents in the last week.":"Aucun incident au cours de la semaine écoulée."}
\ No newline at end of file
diff --git a/apps/web/src/yuzu/server.ts b/apps/web/src/yuzu/server.ts
new file mode 100644
index 0000000000..174e304a67
--- /dev/null
+++ b/apps/web/src/yuzu/server.ts
@@ -0,0 +1,8 @@
+import { createI18nServer } from 'next-international/server'
+
+export const { getCurrentLocale, getI18n, getScopedI18n, getStaticParams } = createI18nServer({
+ 'en': () => import('./en.json'),
+ 'es': () => import('./es.json'),
+ 'fr': () => import('./fr.json'),
+ 'de': () => import('./de.json')
+})
\ No newline at end of file
diff --git a/apps/web/yuzu.config.ts b/apps/web/yuzu.config.ts
new file mode 100644
index 0000000000..d31d105f36
--- /dev/null
+++ b/apps/web/yuzu.config.ts
@@ -0,0 +1,24 @@
+export default {
+ defaultLocale: 'en',
+ locales: [{
+ code: 'en',
+ name: 'English',
+ }, {
+ code: 'es',
+ name: 'Español',
+ }, {
+ code: 'fr',
+ name: 'Français',
+ }, {
+ code: 'de',
+ name: 'Deutsch',
+ }],
+ resources: 'src/yuzu',
+ content: [
+ 'src/app/**/*.{tsx,ts,jsx,js}',
+ 'src/components/**/*.{tsx,ts,jsx,js}',
+ ],
+ transformers: ['t', 'scopedT', 'yuzu', 'yz', 'i18n', ''],
+ framework: 'nextjs',
+ tsx: true,
+} as const
\ No newline at end of file