Removing the Default Locale | Internationalization in NextJs 14

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024

Комментарии • 169

  • @heysahilsingh
    @heysahilsingh 10 месяцев назад +2

    Everything is just PERFECT, I’ve found the best channel on NextJs tutorial I guess :). Just a feedback, in case you might want, try to talk a little fast. Just a little, somewhere around 1.15 - 1.25x

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Welcome onboard! I'm glad to hear that! Thanks for the feedback, I'll try 😅

    • @amelianceskymusic
      @amelianceskymusic 10 месяцев назад +1

      It's easy to speed up the video in the RUclips player itself, but not so easy to slow it down while maintaining decent quality

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      @@amelianceskymusic That's right :)

  • @andresgiovannicanasrodrigu7301
    @andresgiovannicanasrodrigu7301 7 месяцев назад +1

    Wonderful. This video is gold. You are the only one talking about this topic. Do you think that is good idea, check the language saved in the user DB to set the locale in middleware? Some like: "const locale = user?.language ?? getLocale(request);"

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      Thank you! I'm glad you found the video helpful. And yes you can store user language preference in db.

  • @msarlak1512
    @msarlak1512 Месяц назад +2

    hi sir thank you
    i want to use. fa and en
    and fa as default but i think code will be read by default AcceptLanguage
    i cannot set to fa(farsi) as default

    • @hamedbahram
      @hamedbahram  Месяц назад

      You can change the default language of your browser, or update the code so it saves the user selection in local storage if you want to overwrite the browser default. I will have an updated video on i18n soon.

  • @BestinaTV
    @BestinaTV Месяц назад

    دمت گرم آفا حامد عزیز عالی بود💖

  • @amirfarahani6580
    @amirfarahani6580 8 месяцев назад +1

    hi, thank hamed, i flow your video, and clone project. but in the path write a worng character like this:localhost:300/en/assd goes to infinty loop localhost:300/en/en/en/en/en/...assd why this?

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      Not sure why that's happening. It doesn't happen on my end. Check here → next-i18n-ten.vercel.app/

    • @amirfarahani6580
      @amirfarahani6580 8 месяцев назад

      @@hamedbahram i use basePath in next.Config.js Can this be the reason for this?

  • @ceza121121
    @ceza121121 6 месяцев назад +1

    This is good but how we can use interpolation ?

    • @hamedbahram
      @hamedbahram  6 месяцев назад

      I'm not sure, I think you'd have to use a third-party library for that.

  • @sp4mdev
    @sp4mdev 10 месяцев назад +1

    Just wondering how we could generate static route for ‘/‘ and other routes that will be rewritten with the default lang?
    For now I’m assuming that the main entry ‘/‘ will be always dynamic?

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Exporting `generateStaticParam` from the root layout will make sure that all pages are built statically. Remember the root `/` is also rewriting to `/en` under the hood.

    • @sp4mdev
      @sp4mdev 10 месяцев назад

      ​@@hamedbahramYes, if I haven't misunderstood, don't we need the static route for '/', since we are rewriting it with '/en'?
      In your current example, the routes are generated as `/en` instead of `/`, and I'm assuming that will make the landing page as dynamic.
      AFAIK we need to return the param (e.g. 'lang') in `generateStaticParam` but we can't since no param exists for '/' (passing '/' directly will break the app).

    • @sp4mdev
      @sp4mdev 10 месяцев назад +1

      @hamedbahram So you're saying that since `/en` is generated, and when we access `/` we'll rewrite the `/en` and the contents of `/en` are ready to go, it'll almost act as if we statically generated `/`, is that correct?

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      @@sp4mdev yup!

  • @luisgerardocontreras6612
    @luisgerardocontreras6612 10 месяцев назад +1

    Ok, and when working with the src folder, which I am doing, I have problems with the import urls, so I used @/, what could I be doing wrong?

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Look inside your js.config or ts.config if using TypeScript and see what import alias you're using.

  • @arefpasha
    @arefpasha 9 месяцев назад

    thank mr hamed for this useful video

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Glad you found it useful!

  • @amelianceskymusic
    @amelianceskymusic 10 месяцев назад +1

    Do I understand correctly that when changing the language, we lose the search params in the address bar?

    • @amelianceskymusic
      @amelianceskymusic 10 месяцев назад

      I use const searchParams = useSearchParams(); and add its to path `${path}?${searchParams }`

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Hmm 🤔 good question! we might need an update here...

  • @Foused87
    @Foused87 9 месяцев назад +1

    How can I use that with zod for custom errors based on user localization?

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      🤔 Good question! I'm not sure.

  • @szymon2806
    @szymon2806 13 дней назад

    It doesn't work... I can access the homepage with / and with /en.

    • @hamedbahram
      @hamedbahram  10 дней назад

      Not sure what you mean by it doesn't work!

  • @fungau1243
    @fungau1243 10 месяцев назад +1

    Hi hamed,
    I followed the video in your previous video.
    However, it's giving 404 error. Reason for that i that it does not redirect to 'en'.
    it goes to 'localhost:3000/' instead of 'localhost:3000/en'
    How do I make it goes to '/en' ?
    I feel like it's not routing based on the default locale.

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      You can clone my code (link in the video description) and compare your code to mine and see what you're doing differently.

  • @d4rzk252
    @d4rzk252 2 месяца назад

    Hi, I found a bug that breaks the whole thing, just change the default locale to "de" and you can't change the language, I've been trying to fix it for a really long time but I really don't know how anymore, could you help me please? For my page I just need a default language other than "en" and when I change it to anything else it doesn't work anymore after that.

    • @hamedbahram
      @hamedbahram  2 месяца назад

      I'll have a look!

    • @d4rzk252
      @d4rzk252 2 месяца назад

      @@hamedbahram Thanks.. If you can't reproduce it, I'll make a video of what it does..

    • @hamedbahram
      @hamedbahram  2 месяца назад

      @@d4rzk252 sure that can be helpful!

    • @d4rzk252
      @d4rzk252 2 месяца назад

      @@hamedbahram I cannot post a link here

    • @d4rzk252
      @d4rzk252 2 месяца назад

      @@hamedbahram I sent u the video via your portfolio form

  • @wakibtz7134
    @wakibtz7134 7 месяцев назад

    I make internationalization like you and i have a question. SORRY FOR SPAMING, i just have project now with soon deadline. I need to make pagintaion, but if i make Internationalization with removing the default locale, i cant get search params, if a do with default locale, i can, why?

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      What happens to your search params when removing the default locale?

    • @wakibtz7134
      @wakibtz7134 7 месяцев назад

      @@hamedbahram It's okey now, i fixed, i dont shure thats best solution but it works thanks. Problem was, when i go to next page in pagination for exemple, my middleware navigate me to page without queries. So i added in meddleware if i have queries -> add them to route.
      return NextResponse.rewrite(
      new URL(
      `/${locale}${pathname.startsWith("/") ? "" : "/"}${pathname}${
      !queries ? "" : "?" + queries
      }`,
      request.url
      )
      );
      (Sorry for my english :)

  • @max_cr_it
    @max_cr_it 5 месяцев назад +1

    Props drilling with lang looks very bad for me 😒

    • @hamedbahram
      @hamedbahram  5 месяцев назад

      You can use the `use` hook to resolve the translation object in a client component and/or share it via context. See this video for the `use` hook → ruclips.net/video/oMvW3A_IRsY/видео.html

  • @Foused87
    @Foused87 10 месяцев назад

    All files from /public folder can't load. How can I fix that?

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      You can copy all your images into an `images` folder inside the `public` folder and then exclude the `images` folder from running the middleware inside the config matcher like ↓
      ```
      export const config = {
      matcher: ['/((?!api|_next/static|_next/image|favicon.ico|images).*)']
      }
      ```

  • @KaMZaTa
    @KaMZaTa 10 месяцев назад +4

    Hi Hamed! What about url translation? That's really important speaking about SEO! You never mentioned it!

    • @hamedbahram
      @hamedbahram  10 месяцев назад +5

      You're right that is important for SEO. I'll try that in future videos

    • @KaMZaTa
      @KaMZaTa 10 месяцев назад

      @@hamedbahram That would be great! Thanks!

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      @@den9943 How about using a translation object to map URLs and redirect in the middleware function?

  • @joaomaia9140
    @joaomaia9140 6 месяцев назад +1

    Thx, how to know what is the current lang, on the lang switcher? locale !== pathName.split('/')[1], but is not working

    • @hamedbahram
      @hamedbahram  6 месяцев назад

      It'd be your default locale, since we're removing the default locale from the URL. Alternatively you can set a custom header in your middleware to get the current locale.

  • @averelgr
    @averelgr 7 дней назад +1

    Hi Hamed. You saved our lives! I would like to ask you what if I don not want to support /en/something but only /something and /de/something, and in case of /en/something I should redirect to /something. What would be the suggested way and to be aligned with SEO standrds in order not to have errors in Google Search Console?

    • @hamedbahram
      @hamedbahram  5 дней назад

      Isn't what I showed in the video the solution you're looking for?

    • @averelgr
      @averelgr 5 дней назад

      @@hamedbahram At the solution on the video, if you navigate to /en/something work as expected. I case of /en/somehting I want to redirect with the correct SEO way to /something.

  • @mother_chucker12
    @mother_chucker12 3 месяца назад +1

    Thank you for the video. I have a question, how would you implement internationalization and localization (multi-region and multi-translation site) in Nextjs 14, like /[lang]/[region], with removing the default locale and region.
    Is it possible?

    • @hamedbahram
      @hamedbahram  3 месяца назад

      My pleasure! It would be a very similar concept to what we've done here.

    • @mother_chucker12
      @mother_chucker12 3 месяца назад

      @@hamedbahram could you maybe create a video / repository with an example? I'm struggling with that... The default one if you go to '/' would be '/en/row' (both hidden from the url that user sees).
      Regions -> row, eu, us and au

  • @jarekch.3659
    @jarekch.3659 5 месяцев назад +1

    Now we have /about and /en/about? Two urls for the same site? Is that correct for SEO?

    • @hamedbahram
      @hamedbahram  5 месяцев назад

      well /en/about redirects to /about

  • @nicolasaraujo4757
    @nicolasaraujo4757 6 месяцев назад +1

    I got a bug. My default locale is pt, if I change my location to USA I can't change my locale for pt, the app automatically comes back to en. It only occurs with the default locale, spanish works fine. My code is equal to yours.

    • @hamedbahram
      @hamedbahram  6 месяцев назад +1

      I see... I'll have a look at it.

    • @alexla1337
      @alexla1337 4 месяца назад

      @@hamedbahram Ya, I got this bug too. If default locale != browser local, so it's not work. I will try fix it.
      Upd: So you need in middleware to remove "getLocale" function and change where if pathnameIsMissingLocale - make this: "const locale = i18n.defaultLocale;" - Its help to me. After that browser locales will be disabled, and work url path locales only.

  • @naleon-yr5ss
    @naleon-yr5ss 5 месяцев назад +1

    Everything works fine in a test environment, but in a production build, access to / will get a 308 redirect to /en. How can I solve it?

    • @hamedbahram
      @hamedbahram  5 месяцев назад

      Not sure! I haven't had this problem on my deployed version.

    • @KeepItFresh02
      @KeepItFresh02 Месяц назад

      I am having the same problem. local works fine, but prod is abit off. both have same configurations.

  • @pauloalves2840
    @pauloalves2840 День назад

    i refreshed the page and my comment disappeared? can you see it?

  • @kakun7238
    @kakun7238 8 месяцев назад +1

    RangeError: Incorrect locale information provided I am getting this error when i try to go to the / route i need to go /en then only it works anyone facing this issue even after doing the above

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      Hmm 🤔 Not sure what that error is, It's working fine on my end.

    • @kakun7238
      @kakun7238 8 месяцев назад +1

      I found it bc I had put ne_NP as a locale

  • @sonakissonaki
    @sonakissonaki 5 месяцев назад +1

    Hi Hamed, this is great work really. However, I seem to be running into an issue with locale-switcher. Say, in my i18n.config I have defaultLocale: 'de' and locales: ['en', 'de']. When the browser language is 'de' everything works. However, if the browser language is 'en', then localhost:3000 is redirected to localhost:3000/en. At this point a user attempting to switch the language via the button 'de' breaks the code. Am I missing something here?

    • @hamedbahram
      @hamedbahram  5 месяцев назад

      Hmm 🤔 let me check this...

    • @whisky961
      @whisky961 3 месяца назад

      @@hamedbahram have you checked yet? it's very annoying.
      I am trynna debug it myself, nothing so far.

    • @d4rzk252
      @d4rzk252 2 месяца назад

      @@whisky961did u fix this? I have same problem…

  • @kazinafizanam9397
    @kazinafizanam9397 7 месяцев назад +1

    According to your localization video, i have implemented the language switch system.
    but the issue I am getting is from the middleware you created. i am not getting my static files from the public folder.
    export const config = {
    // Matcher ignoring `/_next/` and `/api/`
    matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
    };
    suppose I remove this matcher string and put simple "/" the static files load properly. can you tell me the solution? what do I need to change? please. thanks

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      You have to put your images inside an `image` folder inside the public folder.

    • @kazinafizanam9397
      @kazinafizanam9397 7 месяцев назад

      @@hamedbahram they are.. but still not show up if I do /images/home/banner.png for example...

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      @@kazinafizanam9397 The folder needs to match whatever you passed to the config. For example if it is `image` then the path needs to be `/image/..` and not `/images/...`

    • @kazinafizanam9397
      @kazinafizanam9397 7 месяцев назад

      @@hamedbahram you should have checked your code once... the issue is in your middleware function... i have rewritten the middleware it works fine now...

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      @@kazinafizanam9397 If you don't know how to add a folder to the config matcher don't blame it on the code.

  • @wakibtz7134
    @wakibtz7134 8 месяцев назад +2

    Hi! I have a problem. When i made internationalization i can not get images from public folder. How can i fix it? I tried clone your code from github and put image there but same problem

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      You can copy all your images into an `images` folder inside the `public` folder and then exclude the `images` folder from running the middleware inside the config matcher like ↓
      ```
      export const config = {
      matcher: ['/((?!api|_next/static|_next/image|favicon.ico|images).*)']
      }
      ```

    • @wakibtz7134
      @wakibtz7134 8 месяцев назад +1

      @@hamedbahram Yo man thank you so much!

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      @@wakibtz7134 anytime!

  • @amxwarestudios
    @amxwarestudios 7 месяцев назад +1

    Hi Hamed, I followed your tutorial and i'm glad I figured out all the server and client components issue that has been bugging me for hours. The problem I have now is how do we persists this language preference of the user? I know about cookies and Docs mentioned NEXT_LOCALE cookie but I'm not quite sure what it wants or does. Does Next automatically handle the persistence of the preference with the middleware we setup?

    • @hamedbahram
      @hamedbahram  7 месяцев назад

      Next doesn't persist anything inside the middleware, it just reads the request headers every time. You can add a cookie to keep track of that.

  • @EduardoSotoTi
    @EduardoSotoTi 9 месяцев назад +1

    Hi Hamed, thank you for your videos; they have been very helpful to us. For this reason, I wanted to ask if you have any idea or if you could make a video on how to use not-found.tsx, robots.ts, sitemap.ts, and manifest.ts. These files were working before implementing i18n, but now they aren't. Thank you very much from Chile.

    • @hamedbahram
      @hamedbahram  9 месяцев назад +1

      That's a good question. Unfortunately implementing the `not-found` page with internationalization is not that straight forward. Here is a work-around → github.com/i18nexus/next-i18n-router/issues/36#issuecomment-1821887026

  • @juanferrer5885
    @juanferrer5885 10 месяцев назад +1

    Hi Hamed, do you know where i should include my not-found file? For some reason if i put inside [lang] directory doesn't do anything. Great video btw!!

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Good question! As of right now the `not-found` file doesn't work inside dynamic segments e.g. `[lang]`. A work around is to create a catch all page `[...not_found]` and invoke the `notFound()` function inside of it to render the `not-found` page inside your dynamic path.

  • @udhay2909
    @udhay2909 10 месяцев назад +1

    Hi Hamed, I am continuously watching your vidoes, all of the things are very useful in my projects, Can you plz make the video about socket and it's connections
    in next js

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      Glad to hear that Udhay! Absolutely I'll cover socket in NextJs. Thanks for the suggestion.

  • @zakidzz
    @zakidzz 9 месяцев назад +1

    thank you for this but want to ask how to do client component? also , how about if i was fored to SSR on request how to code split the translation

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Only pass in the specific translation to your client components or share the dictionary via a global state management.

  • @kursatpolatci
    @kursatpolatci 4 месяца назад +1

    Thank you so much. i had searched so much this subject. but i didn't find anthing. finally i made it thanks

    • @hamedbahram
      @hamedbahram  4 месяца назад

      You're welcome! Glad to hear that.

  • @iantolmay1902
    @iantolmay1902 2 месяца назад

    Love the explanation! ❤ Definitely a sub from me.
    Quick question. Removing the default default locale is good for seo purposes? If a website already has seo, and wants to migrate to nextjs with internationalization?

    • @hamedbahram
      @hamedbahram  2 месяца назад

      I'm not sure how removing the default locale would affect the seo, not an expert in that domain.

  • @Sorkstryparen
    @Sorkstryparen 8 месяцев назад +1

    Awesome content as always. Would also love!! a video on this topic but using a cookie-based strategy instead. To opt-out of the route-based solution.

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      I appreciate that. Thanks for the suggestion.

  • @ryanpratama14
    @ryanpratama14 9 месяцев назад +1

    How about making the browser remember the user's last preferred language?

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Yeah you can write the locale to the local storage but you won't be able to read that inside the middleware.

  • @amelianceskymusic
    @amelianceskymusic 10 месяцев назад +1

    Thank you. Next question: how to provide the dictionary without props drilling=)))

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      You can share via React context or any other global state management for that matter.

    • @amelianceskymusic
      @amelianceskymusic 10 месяцев назад +1

      @@hamedbahram It sounds simple, but if you have a lot of child components - client side + server side - I have a lot of questions. I have not been able to solve this issue yet. Some other libraries have special functions/hooks for this

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      @@amelianceskymusic That's right other libraries usually expose a hook to access the dictionaries in client components. I'll try to add a part III video to this series covering that :)

  • @tarifalhasan8749
    @tarifalhasan8749 6 месяцев назад +1

    but what if I fetch data from API ?

    • @hamedbahram
      @hamedbahram  6 месяцев назад

      What do you mean by that?

    • @tarifalhasan8749
      @tarifalhasan8749 6 месяцев назад +1

      @@hamedbahram i mean i will receive the whole translation json from an API call. Not static JSON data

    • @hamedbahram
      @hamedbahram  6 месяцев назад

      @@tarifalhasan8749 Yeah that's fine too, you can fetch the data from a remote API.

    • @tarifalhasan8749
      @tarifalhasan8749 6 месяцев назад

      could you please make a video for remote API 🙏​@@hamedbahram

  • @EA-nr9hc
    @EA-nr9hc 5 месяцев назад +1

    Thank you so much! You saved me after hours and hours of googling

  • @krisporovarde9370
    @krisporovarde9370 8 месяцев назад +1

    Hi, after using this method and trying to index the pages in google search console I get an server error "Page is not indexed: Server error (5xx)" is there something I could do? thanks

    • @hamedbahram
      @hamedbahram  8 месяцев назад

      Which one of the pages are not indexed?

    • @krisporovarde9370
      @krisporovarde9370 8 месяцев назад

      I used this on my own project, previously the pages were all indexed. After adding the no default locale the server error occured, but when I try the pages links in the url they work just fine@@hamedbahram

  • @liviabellomi
    @liviabellomi 8 месяцев назад +1

    Sorry if this question has already been asked, but how do I translate a component that has some hooks (therefore client components) on it once the hooks cannot be called in async functions?

    • @hamedbahram
      @hamedbahram  8 месяцев назад +1

      No worries! You can pass the required translation scope as props to the client component or share it via global state. I will create a video on this next week since it's been asked quite often :)

    • @liviabellomi
      @liviabellomi 8 месяцев назад

      Thanks a lot! 😊

  • @alexeysmirnov9288
    @alexeysmirnov9288 6 месяцев назад +1

    Thank Hamed for this useful video! Just in time)

  • @nikmat
    @nikmat 9 месяцев назад +1

    the middleware is not triggering for "/" route, for all other paths, middleware gets triggered and it rewrites or redirects as expected but for the root path middleware is not running. any idea on what the problem might be?

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Can you expand on that... Do you mean it's not removing the default locale?

    • @nikmat
      @nikmat 9 месяцев назад

      @@hamedbahram if I enter the “/“ in browser, I get 404, since it needs something in place of [lang], which should be added/rewritten inside our middleware right?. All other route paths like “/en/about” or simply “/about” works because middleware is intercepting those ones.
      I solved it finally, the issue was with config matcher, it not only stops all the static files paths but also the root path. So I removed the matcher and added a IF statement which calls next() for all the paths that doesn’t need [lang] at beginning.
      I directly copied from your GitHub and just removed the types since I’m in js.
      Hope you understand now, English isn’t my favourite language, sorry.

    • @shalkar.koshenayev
      @shalkar.koshenayev 9 месяцев назад

      ​@@hamedbahramyes
      I have the same problem(((
      Help please!

  • @SoufianeElkarnoubi
    @SoufianeElkarnoubi 10 месяцев назад +1

    Hi Hamed, thank you very much !!! You helped me a lot today !!! A spent few hours to understood this part of next and this video save me lot of time !! thx !!

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      You're welcome, Soufiane! I'm glad to hear it helped.

  • @ZacharyStout-o5n
    @ZacharyStout-o5n 9 месяцев назад +1

    Awesome video! Thanks for it! Any chance you can speak on how to pass these translations to a client component? I'm having a lot of issue in that regard! Thanks again!

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      I'll probably make a video on that.

    • @ZacharyStout-o5n
      @ZacharyStout-o5n 9 месяцев назад

      @@hamedbahram 😍😍😍

    • @Kruspe616
      @Kruspe616 7 месяцев назад

      ​@@hamedbahram Are there still plans to make that?

  • @arvin6
    @arvin6 9 месяцев назад +1

    Hi Mr. Hamed,
    Your tutorial on using Next.js for a multi-language website has been a real lifesaver for me. I've learned a lot about using next-intl for fixed content, but I've run into a challenge with dynamic content like user-created posts and comments. I'm not sure how to add them to the locales JSON files, and I've had trouble finding helpful resources on this topic.
    I would be really grateful if you could point me in the right direction and maybe even consider creating a tutorial on handling dynamic content within the locales JSON files. Your help would mean a lot to me and others facing similar challenges.
    Thank you so much,

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      Hey Arvin! Glad to hear you fount the videos helpful. As far as dynamic user generated content, I would store then in a database instead of trying to write them to JSON files. You can store all your translations and the dynamic content on a database. Does this make sense?

    • @arvin6
      @arvin6 9 месяцев назад +1

      ​@hamedbahram Thank you for replying so quickly. It makes a lot of sense now 🙏🏻💙. That explains why I couldn't find any resources about it.

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      @@arvin6 No worries man! Glad to help.

    • @arvin6
      @arvin6 9 месяцев назад

      @@hamedbahram 🙏🏻

  • @quizproject-n1k
    @quizproject-n1k 6 месяцев назад

    Hi, i tried to use this dictionary function called getDictionary as "use server" and get error Error: dictionaries[locale] is not a function was trying with async,await then return dictionary but error still showing...

    • @hamedbahram
      @hamedbahram  6 месяцев назад

      What are trying to do? no need for `use server` look at my code, we're fetching data on the server.

    • @quizproject-n1k
      @quizproject-n1k 6 месяцев назад

      @@hamedbahram i thought "use server" is replace for server-only because in that moment intl doesnt support use server...

  • @fakhrulislamfuad8072
    @fakhrulislamfuad8072 10 месяцев назад +1

    This video was quite informative.. but bro.. please upload your next video on translating the not-found page efficiently

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      Thanks! I don't know what's with this, but I keep forgetting 😭

    • @fakhrulislamfuad8072
      @fakhrulislamfuad8072 10 месяцев назад

      @@hamedbahram so sorry to bother but it would be more than appreciating if you do something regarding the issue.. Thanks in advance bro😃

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      @@fakhrulislamfuad8072 Hey! I haven't found a way to implement the `not-found` page in this folder structure. I will continue digging into this...

    • @fakhrulislamfuad8072
      @fakhrulislamfuad8072 10 месяцев назад

      @@hamedbahram thank you so much bro..

  • @denissirenko309
    @denissirenko309 9 месяцев назад +1

    Thank you very much !!!

  • @Foused87
    @Foused87 10 месяцев назад +1

    veeeery helpful, thanks

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      You're welcome :) Glad it was helpful!

  • @irfanulislamjishan4416
    @irfanulislamjishan4416 10 месяцев назад +1

    Great video. loved it.

  • @ps__9979
    @ps__9979 10 месяцев назад +1

    Nice tutorial, Hamed
    There is an issue with images (or any files for that matter) from public folder. They not loading
    Do you have any solution for that?
    thank you

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      You need to exclude your `images` folder from the config matcher.

    • @ps__9979
      @ps__9979 10 месяцев назад +2

      @@hamedbahram thx
      I see now that my reply from yesterday was deleted (probably bc of the link in comment)
      i actually linked stackoverflow answer with solution in middleware it self...in my case I couldn't set matcher to work properly
      maybe for the third part to implement one of the libraries that support complex string syntax...just a thought
      or setting lang in NEXT_LOCALE cookie
      thank you for hq tutorials

    • @hamedbahram
      @hamedbahram  10 месяцев назад

      @@ps__9979 My pleasure! Thanks for the update.

    • @Foused87
      @Foused87 10 месяцев назад

      ​@@hamedbahramhow exactly can I do that?

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      @@Foused87 You can copy all your images into an `images` folder inside the `public` folder and then exclude the `images` folder from running the middleware inside the config matcher like ↓
      ```
      export const config = {
      matcher: ['/((?!api|_next/static|_next/image|favicon.ico|images).*)']
      }
      ```

  • @vincentbobinski5564
    @vincentbobinski5564 9 месяцев назад

    IMHO this is sooooo unnecessarily complex! Really bad job done by vercel. using i18 should be doable with only a view lines of config code.

    • @hamedbahram
      @hamedbahram  9 месяцев назад

      It's definitely not as straight forward as adding i18n to the `pages` router.

  • @askarzhaanbaev5834
    @askarzhaanbaev5834 10 месяцев назад

    Could u please build this project? it still will work? maybe with output export.

    • @hamedbahram
      @hamedbahram  10 месяцев назад +1

      This project is using middleware and won't work with static export. But you can see the built and deployed version here next-middleware-chain.vercel.app

  • @TheSummerPro
    @TheSummerPro 8 месяцев назад +1

    Grazie mille!!