fixed multi language

This commit is contained in:
2026-04-15 12:55:25 +03:30
parent 817bad53ec
commit f915213c16
7 changed files with 21 additions and 19 deletions

5
messages/ar.json Normal file
View File

@@ -0,0 +1,5 @@
{
"Home": {
"title": "goodbye"
}
}

View File

@@ -1,5 +1,5 @@
{
"Home": {
"title": "Title"
}
"Home": {
"title": "hello"
}
}

View File

@@ -1,4 +0,0 @@
{
"loading": "درحال دریافت داده",
"error_fetch_data": "مشکلی در دریافت داده رخ داده است."
}

2
next-env.d.ts vendored
View File

@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

View File

@@ -1,10 +1,10 @@
export type Direction = 'ltr' | 'rtl'
export type Direction = "ltr" | "rtl";
export const localeDirectionMap: Record<string, Direction> = {
en: 'ltr',
fa: 'rtl',
}
en: "ltr",
ar: "rtl",
};
export function getDirection(locale: string): Direction {
return localeDirectionMap[locale] ?? 'ltr'
return localeDirectionMap[locale] ?? "ltr";
}

View File

@@ -6,6 +6,8 @@ export default getRequestConfig(async ({ requestLocale }) => {
const requested = await requestLocale;
const locale = hasLocale(routing.locales, requested) ? requested : routing.defaultLocale;
console.log("locale: ", locale);
return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default,

View File

@@ -1,8 +1,7 @@
import { defineRouting } from 'next-intl/routing'
import { defineRouting } from "next-intl/routing";
export const routing = defineRouting({
locales: ['en', 'fa'],
defaultLocale: 'en',
localePrefix: 'never',
localeDetection: false,
})
locales: ["en", "ar"],
defaultLocale: "en",
localePrefix: "never",
});