19 lines
597 B
TypeScript
19 lines
597 B
TypeScript
// i18n/request.ts
|
||
import { getRequestConfig, type GetRequestConfigParams } from "next-intl/server";
|
||
import { notFound } from "next/navigation";
|
||
|
||
export const locales = ['uz','ru'];
|
||
|
||
export default getRequestConfig(async ({ locale }: GetRequestConfigParams) => {
|
||
// Agar locale undefined yoki not supported bo‘lsa, 404
|
||
if (!locale || !locales.includes(locale)) notFound();
|
||
|
||
// endi TypeScript uchun locale string ekanligi aniq
|
||
const messages = (await import(`../locales/${locale}.json`)).default;
|
||
|
||
return {
|
||
locale, // string, undefined emas
|
||
messages, // JSON fayl
|
||
};
|
||
});
|