اذهب إلى المحتوى
  • 0

تحديد timeZone في مشروع nextjs next-intel

محمود_سعداوي

السؤال

السلام عليكم.

أواجه مشكل في ضبط timeZone  حيث يظهر الخطأ التالي

IntlError: ENVIRONMENT_FALLBACK: There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone
********************
originalMessage: 'There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone'

الكود.

next.config.js

/** @type {import('next').NextConfig} */

const nextConfig = {};

const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");

module.exports = withNextIntl(nextConfig);

src/i18n.ts

import { getRequestConfig } from "next-intl/server";

export default getRequestConfig(async ({ locale }) => ({
  messages: (await import(`../messages/${locale}.json`)).default,
}));

middleware.ts

import createMiddleware from "next-intl/middleware";

export default createMiddleware({
    locales: ["en", "fr", "ar"],
    defaultLocale: "ar",
});

export const config = {
    matcher: ['/((?!api|_next|.*\\..*).*)'],
}

شكرا لكم

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

مكتبة next-intl تحتاج إلى ضبط المنطقة الزمنية TimeZone، فإعدادك الحالي لا يحددها، أي المشكلة ليست في ملفات i18n.ts أو middleware.ts، بل في عدم تحديد المنطقة الزمنية في تطبيقك.

ستجد توضيح في المستند الرسمي:

يخبرك كيفية القيام بالأمر.

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

ستجد في رسالة الخطأ رابط يوجهك للتوثيق الرسمي لكيفية حل تلك المشكلة والتي تكمن في  عدم تحديد المنطقة الزمنية والتي قد تؤدي إلى مشاكل بسبب إختلاف البيئات .

والتعديل كالتالي في ملف next.config.js :

/** @type {import('next').NextConfig} */

const nextConfig = {
 timeZone: 'Europe/Vienna'
};

const withNextIntl = require("next-intl/plugin")("./src/i18n.ts");

module.exports = withNextIntl(nextConfig);

وفي ملف src/i18n.ts :

import { getRequestConfig } from "next-intl/server";

export default getRequestConfig(async ({ locale }) => ({
  messages: (await import(`../messages/${locale}.json`)).default,
  timeZone: 'Europe/Vienna'
}));

ويمكنك تغير المنطقة الزمنية Europe/Vienna إلى المنطقة التي تريدها.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...