fixed multi language
This commit is contained in:
5
messages/ar.json
Normal file
5
messages/ar.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Home": {
|
||||
"title": "goodbye"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Home": {
|
||||
"title": "Title"
|
||||
}
|
||||
"Home": {
|
||||
"title": "hello"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"loading": "درحال دریافت داده",
|
||||
"error_fetch_data": "مشکلی در دریافت داده رخ داده است."
|
||||
}
|
||||
2
next-env.d.ts
vendored
2
next-env.d.ts
vendored
@@ -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.
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user