Internationalization in NextJs 13

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ก.ย. 2024

ความคิดเห็น • 387

  • @benjamingoller6267
    @benjamingoller6267 4 หลายเดือนก่อน +27

    Thanks for the work! For me personally, it is not ideal that you don't write but only show the code, that does not help me understand how things work together. You only explaining the code sure helps, but it leads to you leaving out quite a few things (parts of the code and structure) that I just copy paste. Sure, I can figure it out myself, but that sort of beats the purpose of a video like this. Just my opinion, but other people seem to like that style...

    • @hamedbahram
      @hamedbahram  4 หลายเดือนก่อน

      Thanks for sharing your feedback. I get it and will have it in mind for future videos.

  • @dzeej1
    @dzeej1 ปีที่แล้ว +8

    Man! I am so happy I’ve found your channel. I love the way you explain topics and covering server components just makes my work easier. Thanks🙏🏼

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      I'm glad to hear that man! Appreciate your comment!

  • @pauloalves2840
    @pauloalves2840 3 หลายเดือนก่อน +1

    I have been struggling to piece all these concepts together onto my app, but the way you structure the video with an initial overview of the code and then its implementation is amazing!

    • @hamedbahram
      @hamedbahram  3 หลายเดือนก่อน +1

      Glad it was helpful! I appreciate your comment.

  • @ilaydaozel4851
    @ilaydaozel4851 ปีที่แล้ว +2

    Thank you. I have tried other internationalization videos too but this video worked the best for me at the end!

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Glad to hear that Ilayda!

  • @mohsenlotfi3905
    @mohsenlotfi3905 6 หลายเดือนก่อน +1

    Thanks, this is the perfect content to explain the internationalization in the NextJS app directory. The problem that I still have is you have to pass the "lng" string from parent to children in all components. It will be hard to handle If you have a large-scale application. so far, I didn't find a way to fix this problem

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน +1

      Glad it was helpful.

  • @alexeysmirnov9288
    @alexeysmirnov9288 6 หลายเดือนก่อน +1

    Thank you Hamed so much! Excellent step by step explanation. That's just what I've needed. Liked and subscribed.

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      My pleasure! Thanks for the sub!

  • @hosseinjafari2896
    @hosseinjafari2896 4 หลายเดือนก่อน +1

    You're doing amazing.Keep up the good work.

    • @hamedbahram
      @hamedbahram  4 หลายเดือนก่อน

      Thank you!

  • @27sosite73
    @27sosite73 10 หลายเดือนก่อน +1

    the way you structure your videos and follow the documentation is fabulous

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Appreciate it! Glad you think so!

  • @awesome-view
    @awesome-view ปีที่แล้ว +1

    Thanks man!
    I used this implementation and it's working like flash.

  • @Neruu2-g3g
    @Neruu2-g3g ปีที่แล้ว +1

    Another question! :D
    Thanks to your help, I've managed to make it work nicely, even with mixing with an auth middleware. If find the logic very beginner friendly and you approach nice ad clear.
    There is one point you don't point out:
    the next-intl and next-international libraries allows the use of plurals, genders, ... in the dictionaries object allowing something like that:
    {
    "static": "Hello world!",
    "interpolation": "Hello {name}!",
    "plural": "You have {numMessages, plural, =0 {no messages} =1 {one message} other {# messages}}.",
    "select": "{gender, select, female {She} male {He} other {They}} is online.",
    "selectordinal": "It's your {year, selectordinal, one {#st} two {#nd} few {#rd} other {#th}} birthday!",
    "escaped": "Escape curly braces with single quotes (e.g. '{name'})"
    }
    What would be the equivalent for your getDictionary method?
    At the moment I use a t.interpolation.replace('{name}', name) but I don't know how to make it work for the "plural", "select", ... Any chance this could work?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Hey! good question. you can still use those libraries. The `next-int` has stable support for client components and a beta version for server components.

    • @Neruu2-g3g
      @Neruu2-g3g ปีที่แล้ว +1

      @@hamedbahram yes I've checked it out but your solution gets rid of the LocaleProvider (which is why it is such a beginner's friendly approach).
      And the providers fron next-intl... Not so much :D

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      @@Neruu2-g3g that's right!

  • @ariel_chp
    @ariel_chp 9 หลายเดือนก่อน +1

    Amazing tutorial. I log in just to thank you. Thanks a lot!

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      You're welcome! Great to hear that.

  • @m__link6499
    @m__link6499 ปีที่แล้ว +1

    I was waiting for this one for a while…thank you dude, your work rocks…🎉🎉🎉

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      My pleasure! I appreciate your comment 🙏🏽

  • @trusht
    @trusht ปีที่แล้ว +1

    right on time, as i am about to implement this feature.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Awesome! Hope this helps 🚀

  • @user-qw4hk3us4d
    @user-qw4hk3us4d ปีที่แล้ว +1

    Thank you! It really helped with the current project

  • @perseyiis
    @perseyiis 9 หลายเดือนก่อน +1

    Thank you. You are a lifesaver what an amazing content.

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      You're welcome! I appreciate that!

  • @pouriahoseianzadeh8898
    @pouriahoseianzadeh8898 11 หลายเดือนก่อน +1

    Thanks, Helped me a lot to complete my project

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Glad it helped!

  • @AnnaBazdyreva-zf8by
    @AnnaBazdyreva-zf8by 10 หลายเดือนก่อน

    Great job! Thanks a lot for the detailed and clear explanation of internationalization in Next 13. Made my current landing bilingual with this video!

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Glad to hear that, Anna!

  • @juanferrer5885
    @juanferrer5885 ปีที่แล้ว

    Lets gooo! I was waiting for this one! Awesome content as always!

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      There you have it, Juan! I appreciate that.

  • @mohamadabdeen6906
    @mohamadabdeen6906 8 หลายเดือนก่อน +1

    thanks for this great video

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      My pleasure!

  • @komepc
    @komepc 9 หลายเดือนก่อน +1

    Thank you, this was so helpful!

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      Glad to hear that!

  • @AhmedHuzain
    @AhmedHuzain 8 หลายเดือนก่อน +1

    Thank you so much!

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      Glad it helped!

  • @lorisyanis
    @lorisyanis ปีที่แล้ว +1

    Thank you a million, that was so helpful!

  • @user-tz8mw2uk6k
    @user-tz8mw2uk6k 9 หลายเดือนก่อน +3

    This is an awesome video. But I'm running into an issue when trying to add light mode/dark mode. for some reason I can't get it to work! Wondering if you have any suggestions.

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      Hmm 🤔 I wonder why that is... Are you getting any errors?

    • @user-tz8mw2uk6k
      @user-tz8mw2uk6k 9 หลายเดือนก่อน

      Yes, I'm getting this error:
      server error
      TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it.
      This error happened while generating the page. Any console logs will be displayed in the terminal window.
      it points to the next-themes folder in my node modules.
      @@hamedbahram

    • @user-tz8mw2uk6k
      @user-tz8mw2uk6k 9 หลายเดือนก่อน

      TH-cam keeps deleting my comments, I'm getting this error:
      server error
      createContext only works in Client Components. Add the "use client" directive at the top of the file to use it.
      This error happened while generating the page. Any console logs will be displayed in the terminal window.
      it points to the next-themes folder in my node modules.
      I tired added the use client directive to the particular file, but it didn't work... Using shadcn ui BTW

    • @user-tz8mw2uk6k
      @user-tz8mw2uk6k 9 หลายเดือนก่อน +1

      @@hamedbahram I actually figure out the issue. Once upgrading to next 14, adding the 'use client' directive to the file fixed the issue. Not totally sure about the implications of directly editing a node module file are, but it seems to work for now!

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      @@user-tz8mw2uk6k You're not supposed to edit the package in the node_modules folder, instead you have to add the `use clinet` directive on the component you are using the `themeProvider`. Watch this video where I explain this pattern → th-cam.com/video/RTAJ-enfums/w-d-xo.html

  • @filipploss
    @filipploss ปีที่แล้ว +1

    Thanks, man! It's very useful and convenient

  • @onizuka_js1484
    @onizuka_js1484 10 หลายเดือนก่อน +1

    Thanks a lot for this video!

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      You're welcome! Glad you found it helpful.

  • @nicocouss7849
    @nicocouss7849 ปีที่แล้ว +1

    You are helping me a lot. Thx :)

  • @LaurynasKučinskas
    @LaurynasKučinskas ปีที่แล้ว +2

    Amazing content. Could you make a tutorial on how to implement headless cms with multiple languages? I’m trying to do it with Sanity

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +2

      For sure! I have that in my schedule.

  • @bringmemore2621
    @bringmemore2621 11 หลายเดือนก่อน

    Great work mate! Your stuff is very usefull. Keep it going! 🎉🎉🎉

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Glad to hear that! I appreciate it mate 🙂

  • @johnaroj
    @johnaroj 5 หลายเดือนก่อน +1

    hi thanks for this tutorial. can I use this also if I want a dictionary folder or translation folder inside of a component on a app/route/_component library? for better organization?

    • @hamedbahram
      @hamedbahram  5 หลายเดือนก่อน

      Absolutely!

  • @toffanettodev
    @toffanettodev 11 หลายเดือนก่อน +1

    Very, very good!

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Thank you! Cheers!

  • @HigherStudyAspirant
    @HigherStudyAspirant 6 หลายเดือนก่อน +1

    Thanks.I hava a query, I am getting the translation from separate backend API, like the key for english version is the name while translation is name_2; for example receiving the users list from API, [{user:{location:'english-name',location_2:'translated-name'}] and same like for other properties like city and city_2 as keys for english and translated version respectively. Do I still need dictionaries as I am getting the translation from backend and can I reuse the same component because for name I need to show {user.name} but if the language is other(Arabic), then {user.name_2},

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      If the translations are coming from a separate API, you won't need the local dictionaries anymore.

  • @kennedyfreitas7548
    @kennedyfreitas7548 6 หลายเดือนก่อน +1

    is there an example where you implement an actual CMS?? Great video

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน +1

      We have CMS related videos but not with Internationalization. I'm working on a couple of projects for that, so stay tuned.

    • @kennedyfreitas7548
      @kennedyfreitas7548 6 หลายเดือนก่อน

      @@hamedbahram wonderful, what CMS will you consider for the upcoming projects?
      I's recommend SANITYCMS

  • @PetroArva
    @PetroArva 7 หลายเดือนก่อน +1

    Hello! Its super cool, but how to use getDictionary in server or client components without passing lang prop into components? How to avoid prop drilling, especially when we have deep nested components? Should we store lang into state management?

    • @hamedbahram
      @hamedbahram  7 หลายเดือนก่อน

      Yes a global state management can be the solution.

  • @DemiZhao-pi7qp
    @DemiZhao-pi7qp 9 หลายเดือนก่อน

    Clear explanation, thanks

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      Glad it was helpful!

  • @you3667
    @you3667 7 หลายเดือนก่อน +1

    you are great!

    • @hamedbahram
      @hamedbahram  7 หลายเดือนก่อน +1

      Thank you!

  • @QuickSolutions_
    @QuickSolutions_ 6 หลายเดือนก่อน +1

    How to get dictionary in client components as it gives warning to not to use async function in client components?

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      You can pass the required translation scope to the client component as props. Alternatively you can use the `use` hook to get the entire translation. See this video → th-cam.com/video/oMvW3A_IRsY/w-d-xo.html

  • @karolmaj1955
    @karolmaj1955 8 หลายเดือนก่อน +1

    Great video! I just have one question about routering. When user hit "/" path. How Could I redirect him base of default language ? Thanks

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน

      Watch this video → th-cam.com/video/1S7yFzU2ulg/w-d-xo.html

  • @maciejfiglarz4871
    @maciejfiglarz4871 3 หลายเดือนก่อน +1

    how avoid props drilling from page.tsx to nested components?

    • @hamedbahram
      @hamedbahram  3 หลายเดือนก่อน

      See this video → th-cam.com/video/oMvW3A_IRsY/w-d-xo.html

  • @sorooshmlv6340
    @sorooshmlv6340 10 หลายเดือนก่อน +1

    Thanks a lot. I have question what about farsi when one lang is RTL and the other is LTR

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Glad you enjoyed it! To you tailwind for RTL languages, you can check the `lang` parameter in your root layout and add the `dir="rtl"` attribute to your html tag, which then enables you to use the `rtl:` and `ltr:` modifiers in tailwind. You can read more about it here => tailwindcss.com/docs/hover-focus-and-other-states#rtl-support

  • @zillalsenmesrane1022
    @zillalsenmesrane1022 8 หลายเดือนก่อน +2

    thanks for the video , but what about the client components ? how can we implement this in it ? can anyone help please :/

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      Pass down the translations as props to client components or share them via global state. I'll make a video on this since a lot of folks have asked for it.

    • @zillalsenmesrane1022
      @zillalsenmesrane1022 8 หลายเดือนก่อน +1

      @@hamedbahram thank you so much we can't wait for the video ❤

  • @marieltorres2873
    @marieltorres2873 9 หลายเดือนก่อน +1

    Hi Hamed I implemented internationalization in my project using Page to pass the lang property to the child components. However, with many child components, the chain of steps to pass the dictionary through the props becomes complicated. Is there any way to import the dictionary directly from Page child components using SSG?
    I would appreciate your help!

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      Hi Mariel! You can share the dictionary with React context or a global state management like Zustand. Hope this helps. I may create a video on this since it's been asked a lot :)

    • @marieltorres2873
      @marieltorres2873 9 หลายเดือนก่อน +1

      @@hamedbahram
      Thank you for your response, Hamed. However, this is compatible with server components, as using context is for client components.

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      @@marieltorres2873 For server components you can call the `getDictionary` function directly to get the dictionary. For client components you can pass the translation through props or share via global state. Does this answer your question?

    • @joao-pedro-alves
      @joao-pedro-alves 8 หลายเดือนก่อน

      @@hamedbahram I'm facing the same issue. in this case how a server-side component can know which is the current language since only page level components get the current language as a prop?

  • @amershboul9107
    @amershboul9107 ปีที่แล้ว +2

    Bro i found one bug in this approach
    trying to add Image to your project will not work if the image exist in the public folder
    example :
    public
    --- image1.jpg
    it will break
    any fix ?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      Good question, two ways you can go about this, firstly, if you are serving up the image from your public folder its better to statically import your image in any component using it so NextJs would serve it from your `_next/static` folder which is excluded from the i18n middleware. Secondly you can move all your static images into a folder (e.g ./public/images/...) and exclude that folder from the middleware using the config matcher.

    • @amershboul9107
      @amershboul9107 ปีที่แล้ว +1

      @@hamedbahram Thank you so much!

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      @@amershboul9107 anytime!

  • @faramazbaghirov670
    @faramazbaghirov670 9 หลายเดือนก่อน +2

    Hello
    Thanks for great explanation.
    I have added third language. There are 3 languages now. But It's not working properly.
    Thanks

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      I should no matter how many languages you have. Check your i18n config, actual json dictionaries, and the `getDictionaries` function to include the third locale.

    • @faramazbaghirov670
      @faramazbaghirov670 9 หลายเดือนก่อน

      Thanks for your support it was a problem with order of the locale array. finally fixed it. thanks again
      @@hamedbahram

  • @luisgerardocontreras6612
    @luisgerardocontreras6612 7 หลายเดือนก่อน +1

    The detail is when I destructure the Header and create the Navbar, when I place the Navbar inside the Header everything is fine, the problem occurs when I pass the Header to the layout.tsx, it generates an error in the Line where I pass the Header < Header lang = { params.lang } />. with that additional component, it would go one file behind and I don't know what I should call it in the layout

    • @hamedbahram
      @hamedbahram  7 หลายเดือนก่อน

      It maybe that you're importing a server component into a client component. What error are you getting?

  • @pot42
    @pot42 6 หลายเดือนก่อน +1

    How would you approach the topic of i18n if your locale was not stored in your URL, but rather in your user settings, which would be fetched on app load ?

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      I'd fetch the user setting in the middleware and redirect to the correct locale.

    • @pot42
      @pot42 6 หลายเดือนก่อน

      @@hamedbahram What do you mean by "redirect" ? Since the locale is not stored in the URL, I don't see the point of redirects, am I missing something ?

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      @@pot42 I thought you want to read the user preference from your DB instead of the request headers. If you want to implement a different route structure, then you'd need to have dynamic pages that have request specific logic to render content in different languages.

  • @d4rzk252
    @d4rzk252 11 หลายเดือนก่อน +1

    Great video! Finally someone who explained it normally and I understood it. I just have a question, can we somehow catch an error if I select for example a German language and there is no translation for a certain section? The app crashes like that, so if there is some way to handle it, so that the default translation (en) is used and the app doesn't crash. Of course it could be checked in every single file to see if it exists, but that seems stupid to me.
    Thanks!

    • @d4rzk252
      @d4rzk252 11 หลายเดือนก่อน

      And then another question. If I pass translation props to the client component, I have to type them all through typescript. It is annoying if I have a bigger translation to put in, so I have to do it this way? Can't I do it differently and better so I don't have to write it all by hand?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Thank you, I appreciate it! That's a good point, you can definitely put some guardrails to handle cases where the translation doesn't exist.

    • @d4rzk252
      @d4rzk252 11 หลายเดือนก่อน

      Do you have any ideas or tips on how to do this well? And what about typing the props, does it have to be done that way?

    • @d4rzk252
      @d4rzk252 11 หลายเดือนก่อน +1

      @@hamedbahram?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      @@d4rzk252 I don't have any tips or specific implementation recommendations.

  • @Saleh_Balakisiyev
    @Saleh_Balakisiyev 11 หลายเดือนก่อน +2

    Hey Bahram great video, I just have question is it a good idea to store the dictionary files in redux to access it from client components?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Yes you can use Redux for that or React context.

    • @Saleh_Balakisiyev
      @Saleh_Balakisiyev 11 หลายเดือนก่อน +1

      @@hamedbahram Yeah, but useing state to store translations does not seem to be a good practice, I gues I will use next-intl and use a custom function to get server side translations.

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      @@Saleh_Balakisiyev Whatever works better for you.

  • @luisgerardocontreras6612
    @luisgerardocontreras6612 7 หลายเดือนก่อน +1

    Hello so and so, I was trying to remove the Nav from the Header in a new component, but Typescrscript gives me an error in the layout and another thing I am trying to do is change the language buttons inside the locale-switcher, to place the flag And I haven't been able to get it to be a dropdown menu either, could you give me some suggestions or do you know any tutorial for it?

    • @hamedbahram
      @hamedbahram  7 หลายเดือนก่อน

      You'd need a client component for a dropdown and that's probably the error you're getting. You can add the `use client` directive in the beginning of the file.

    • @luisgerardocontreras6612
      @luisgerardocontreras6612 7 หลายเดือนก่อน

      @@hamedbahram In the Header I bring the Navbar () and assign it the 'use client', and I pass the props to the Header ({ params }: { params: { lang: Locale } }) , and then in the layout.tsx I pass the Header above the children , but it gives me the following error:
      "message": "Type '{ lang: "en" | "es" | "pt" | "de"; }' is not assignable to type 'IntrinsicAttributes & { params: { lang: "en" | "es" | "pt" | "de"; }; }'. Property 'lang' does not exist on type 'IntrinsicAttributes & { params: { lang: "en" | "es" | "pt" | "de"; }; }'.",
      install the dropdown menu and the option for the flags in locale-switcher.tsx, I'm trying to do it right now

  • @amouzande9102
    @amouzande9102 5 หลายเดือนก่อน +1

    Hi mr hamed. How to localize view direction for rtl and ltr?

    • @hamedbahram
      @hamedbahram  5 หลายเดือนก่อน

      You can check the `lang` parameter in your root layout and add the `dir="rtl"` attribute to your html tag, which then enables you to use the `rtl:` and `ltr:` modifiers in tailwind.

  • @asemkakhi3284
    @asemkakhi3284 ปีที่แล้ว +1

    I am still confused about this line:
    import 'server-only';
    What is that?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      The `server-only` is a React package you can use on any module that is only meant to run on the server. It will give you a build error if you ever import anything from that module into a client component. It's just a guardrail to make sure your server code stays on the server.

    • @asemkakhi3284
      @asemkakhi3284 ปีที่แล้ว +1

      @@hamedbahram why is that different from just writing "use-server"

    • @asemkakhi3284
      @asemkakhi3284 ปีที่แล้ว

      @@hamedbahram Am I gonna need that if I am using Typescript?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      @@asemkakhi3284 It has nothing to do with `user server`. The `use server` directive is for creating server actions. The `server-only` package is something you can use anywhere in your server code to protect it from being used in client-side.

  • @danestrela
    @danestrela 11 หลายเดือนก่อน +1

    First of all, thanks for the solution! But I need to ask: Have you ever tryed to put an image on /public and return it using ? This solution seems to force the path to the /en for example, and the images does not load...

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +2

      Good question! 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).*)']
      }
      ```

    • @danestrela
      @danestrela 11 หลายเดือนก่อน +1

      @@hamedbahram Heey thanks for the response ;) Do you think I can make a blog post for it? I'm starting a blog full based on solutions and value, would be cool if I could mention your project :D

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      @@danestrela For sure man! go for it.

  • @arazmmmdli6126
    @arazmmmdli6126 10 หลายเดือนก่อน +1

    We created a lang inside the application folder and did everything inside it, but how do we use the not found file in this situation? How can I make the contents of the not found file to be included in the layout inside the lang folder?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      That's a good question! I haven't found a way to implement the `not-found` page in this folder structure. I will continue digging into this...

  • @wingmann3632
    @wingmann3632 9 หลายเดือนก่อน +1

    Coool, thx

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      My pleasure!

  • @claudivan.dev_
    @claudivan.dev_ ปีที่แล้ว

    Thanks, I'm brasilian and your chanel help-me to translate my app

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Glad to hear that! Welcome to the channel.

  • @ebulfezsadiqov9341
    @ebulfezsadiqov9341 ปีที่แล้ว +1

    Hello, how to use this localization for coming data from backend

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      I'm working on a video to show this using a CMS. Stay tuned!

    • @ebulfezsadiqov9341
      @ebulfezsadiqov9341 ปีที่แล้ว +2

      @@hamedbahram i am going to be happy for this,Thanks
      İt is more good to use node js

    • @ebulfezsadiqov9341
      @ebulfezsadiqov9341 11 หลายเดือนก่อน

      @@hamedbahram Hello, Do you work about this piece?

  • @felixhoevelborn
    @felixhoevelborn ปีที่แล้ว +1

    Hey Hamed, i never found a solution for the following. Is it possible to re-direct to the default path (for example /en) without even using it. So /en would be the default (wihout showing that route) and you would only show /de for the alternative pages?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      That's right, with the dynamic `[lang]` segment, we need to have the locale in the URL even for the default `en`.

  • @mohdsahil226
    @mohdsahil226 10 หลายเดือนก่อน +1

    Not able to access public folder for images after implementing i18n. Would you please help?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Good question! 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).*)']
      }
      ```

  • @yazugaming5573
    @yazugaming5573 ปีที่แล้ว +1

    I have a question. I was make link constant that contain array that have href and label. The label it was key of my translation that store in json file of the translation like you show. When I loop through my links I don’t know how to dynamic the translation when it is de structure from getDictionaries.
    In example:
    en.json
    {
    “home”: “ HOME”,
    “about”: “ABOUT”
    }
    Links
    const links = [
    {
    href: “home”,
    label: “home”,
    },
    {
    href: “about”,
    label: “about”
    }
    ]

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You can use dynamic parameters something like `navigation[link.label]`

  • @ilirbajrami2902
    @ilirbajrami2902 11 หลายเดือนก่อน +1

    Implementation with Sanity please!

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Sure!

  • @selimsezer3629
    @selimsezer3629 10 หลายเดือนก่อน

    I can't call the getDictionary function because it says 'use client' at the top. When I delete the 'use client' text, errors appear in other places. How can I fix this?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      You can call the `getDictionary` function in your page server component and only pass the necessary translation scope to your client components.

  • @leof240
    @leof240 7 หลายเดือนก่อน +1

    thanks for teh tutorial. One question though: with the locale, the error and 404 pages reverted to the nextjs ones instead of using mine. how can I force them?

    • @hamedbahram
      @hamedbahram  7 หลายเดือนก่อน +1

      Essentially the issue is that automatic redirects to not-found do not work inside of a dynamic segment like [lang]. So you need to use a catch-all that calls notFound().
      You will need:
      1. Catch all component: [...not_found]/page.tsx
      2. Not found page: not-found.tsx
      ```
      // [...not_found]/page.tsx
      import { notFound } from 'next/navigation';
      export default function NotFoundCatchAll() {
      notFound();
      }
      ```
      Another problem is that inside of your not-found page you will not have access to page params. So you cannot access the locale from page params. You can instead set a custom header in your middleware if you want to localize this not-found page.
      ```
      // not-found.tsx
      import { headers } from 'next/headers'
      export default async function NotFound() {
      const headersList = headers()
      const locale = headersList.get('x-i18n-locale') || 'en'
      ...
      }
      ```

  • @lucasmolenaar64
    @lucasmolenaar64 8 หลายเดือนก่อน +1

    Thanks! How would I do this if my pages aren't server component but client components?

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      Share the translation via global state or pass the scope as props to the client component. But it's best to leave the client component only to the ones that need user interactivity.

  • @matiasdelgado9372
    @matiasdelgado9372 8 หลายเดือนก่อน +1

    Hi Hamed, what is your Vscode font?

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน

      Hey! It's Operator mono.

  • @pablopenia
    @pablopenia 11 หลายเดือนก่อน +1

    what happens when we have content in the database? Currently Im follow this pattern for the UI, and getting the DB content dynamically, by reading the lang param in url I show one field or another in DB. But not sure if ths the way to do it.

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      That can work.

  • @caglayanevren
    @caglayanevren 10 หลายเดือนก่อน +1

    Great explanatory video 🙏 thank you Hamed
    How can I translate 'de/about' path to 'de/uber' in the URL?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      My pleasure, Evren! You'd have to add path translation to your middleware to redirect `de/about` to `de/uber`

  • @WahajHafeez
    @WahajHafeez 4 หลายเดือนก่อน

    is there any approach in which we don't change the Url and save the language in local storage or cookies and then make a button on that button click we change the language ?

    • @hamedbahram
      @hamedbahram  4 หลายเดือนก่อน

      Yes you can do that.

  • @Menix-genziara
    @Menix-genziara 8 หลายเดือนก่อน +1

    Hi thanks for your video I've been using this translation for some time but there's one problem I'm struggling with. What if I'd like to change only one word from json to be bold or change his color. I remember while using useTranslation in react only need to wrap it by bold selector in json and then just use to make it work

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      You'd need to use a third-party library for those functionalities.

  • @user-sj5su4wv9k
    @user-sj5su4wv9k 11 หลายเดือนก่อน +1

    Sorry, I have a problem with getLocale always returning "en"?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Not sure why you have that problem. You can clone my code (link in the description) and compare your code to mine and see where the problem might be.

  • @zabialy2919
    @zabialy2919 ปีที่แล้ว +1

    Is there a way to access the translations in client components? Currently I get the error message that the dictionary.ts file is 'server-only'. Should I just pass the translations as props?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      That's right you can pass them as props.

  • @ShimnaAugustine
    @ShimnaAugustine 4 หลายเดือนก่อน

    Hi, thank you so much for your video. It was really helpful. Could you please suggest the best way to retrieve page labels on the client side? Should I pass labels from parent to child?

    • @hamedbahram
      @hamedbahram  4 หลายเดือนก่อน +1

      Glad to hear that. Yes you can pass it as props or use the `use` hook to retrieve the translation object in client components directly or share it via context. Watch this video → th-cam.com/video/oMvW3A_IRsY/w-d-xo.html

    • @ShimnaAugustine
      @ShimnaAugustine 4 หลายเดือนก่อน +1

      @@hamedbahram Thank you so much for your reply

    • @hamedbahram
      @hamedbahram  4 หลายเดือนก่อน

      @@ShimnaAugustine pleasure!

  • @hqasmei
    @hqasmei ปีที่แล้ว +1

    Woah 🤯

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Thanks for tuning in, Hosna!

  • @dimitrisfilippou
    @dimitrisfilippou ปีที่แล้ว +1

    Soo good channel! Amazing keep it up! Where is the donation page?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Thank you Dimitrios! I don't have a donation page ❤️ subscribing to the channel is the best support 🫡

  • @diegovergaracasanova1159
    @diegovergaracasanova1159 11 หลายเดือนก่อน +1

    is possible show the content of the /en/about in the path /about ? like a default path?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Unfortunately not! with the way this is implemented everything is living inside the `lang` folder.

  • @arjunsv8496
    @arjunsv8496 8 หลายเดือนก่อน +1

    Thank you so much for this content.
    I’m encountering a problem where the act of switching languages (which consequently alters the locale in the URL) is causing interference with the functionality of the browser’s back button. My aim is to guarantee that when the back button is clicked, it directs the user to the preceding page, irrespective of any changes in language. Is there a method to accomplish this?

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน

      You're welcome! How does it interfere with the back button?

  • @z1982_
    @z1982_ ปีที่แล้ว +1

    Hello, thanks a lot for the clear explanation!
    You don't show generateStaticParams right?
    What would be the exact benefit to add it ?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      The `generateStaticParams` will instruct NextJs to generate pages statically and cache them for faster response.

    • @z1982_
      @z1982_ ปีที่แล้ว

      ​@@hamedbahramThanks! Is it normal that all my app is re rednered whenever i change the language ?
      Also, I belive there is an issue with the exclusion with the favicon.ico in the matcher because i get a server side error whenever i change page saying : Error loading dictionary for locale "favicon.ico": TypeError: dictionaries[locale] is
      not a function

  • @kozubskyi
    @kozubskyi 11 หลายเดือนก่อน +1

    In file i18n.config.ts I have
    export const i18n = {
    defaultLocale: 'ua',
    locales: ['ua', 'en'],
    } as const
    But when I reload page at route "/" it redirects me to "/en" insted of "/ua"

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Look at your middleware and see if you're using the correct local. You can compare it to my code and see what you're doing differently.

  • @alishayegh7047
    @alishayegh7047 ปีที่แล้ว +2

    amazing as always! I enjoyed your flow and fluency and you made the topic very interesting and easy to understand. The mood of the video is also very upbeat and fun. I appreciate your hard work!
    a question, how can we add support for right to left languages like persian to this app with tailwind CSS?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +2

      Glad you enjoyed it! To you tailwind for RTL languages, you can check the `lang` parameter in your root layout and add the `dir="rtl"` attribute to your html tag, which then enables you to use the `rtl:` and `ltr:` modifiers in tailwind. You can read more about it here => tailwindcss.com/docs/hover-focus-and-other-states#rtl-support

    • @alishayegh7047
      @alishayegh7047 ปีที่แล้ว +1

      @@hamedbahram I'm going to test it, thanks, I appreciate how you always respond to the comments and interact with your fans. Keep up the good work! 💪

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      @@alishayegh7047 My pleasure Ali Jan!

    • @where2group334
      @where2group334 ปีที่แล้ว

      thx first of all how can i make the check depend on toggole button and change the html can you please explane more@@hamedbahram

    • @alishayegh7047
      @alishayegh7047 9 หลายเดือนก่อน

      ❤@@hamedbahram

  • @icedev8078
    @icedev8078 ปีที่แล้ว +1

    I have a question. I downloaded the Git repository to try and use it. The next folder contains all the exported files, but it's using 7MB. Isn't that high for only 2 static pages? I don't understand why the weight is so high.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      That's actually pretty small for a typical NextJs app. This folder contains all you server and client code, dependencies, as well as static assets. This is not similar to a static export

    • @icedev8078
      @icedev8078 ปีที่แล้ว

      @@hamedbahram yes, I've tested the code. I need to add something more to export it statically. However, if I export it with an "out" folder, I can't use the middleware for the index redirection. The pages work, but the index returns a 404 error. Do you know how to do the same thing with static generation only? Or what could I do since I need to create a website with two languages, but it doesn't have functions, only static content? Best regards, and thank you very much.

  • @zakidzz
    @zakidzz 9 หลายเดือนก่อน +1

    thats soo good but how about client component?????

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน +1

      Thanks! you can pass in specific translations to your client components.

    • @zakidzz
      @zakidzz 9 หลายเดือนก่อน +1

      ​@@hamedbahramyou know a open source key manager? example to manage the keys in i18n or to build it

    • @hamedbahram
      @hamedbahram  9 หลายเดือนก่อน

      @@zakidzz, good question! Nothing off top of my head!

    • @zakidzz
      @zakidzz 9 หลายเดือนก่อน

      @@hamedbahram was thinking of making api route that read the local json and basic page to make crud operations , even for multi files json namespaces would love to see a vedio about it (everything in same next js app) but the route work only in dev version not production

  • @araki.simural
    @araki.simural ปีที่แล้ว +1

    Thanks for your video! I could implement i18n in SSG mode using nextjs 13 app router. But one suggestion - can we omit default language(en) in the router?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      Since everything is living inside the `lang` folder, it's not possible to remove the default local from the URL.

  • @dailyjstutorial
    @dailyjstutorial 11 หลายเดือนก่อน +1

    Can we implement client side ?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      I'd have to create a part II video on that since a lot of folks have asked me. In the mean time you can pass the translation down as props or share via React context.

  • @irfanulislamjishan4416
    @irfanulislamjishan4416 10 หลายเดือนก่อน +1

    redirection from / to /en is not working for me.

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Watch the video that comes out today 🤓

    • @irfanulislamjishan4416
      @irfanulislamjishan4416 10 หลายเดือนก่อน +1

      @@hamedbahram I will. Also solved the redirection problem. middleware.ts file was outside the src directory, worked fine once moved it to src directory. Thank you

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      @@irfanulislamjishan4416 glad to hear you figured it out.

  • @gabrielbianchi2246
    @gabrielbianchi2246 5 หลายเดือนก่อน +1

    What about client components?

    • @hamedbahram
      @hamedbahram  5 หลายเดือนก่อน

      Watch this → th-cam.com/video/oMvW3A_IRsY/w-d-xo.html

  • @fakhrulislamfuad8072
    @fakhrulislamfuad8072 11 หลายเดือนก่อน +1

    Bro, I'm stuck at implementing the localized not-found.tsx page. Can you help??

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Sure, what problem are you facing?

    • @fakhrulislamfuad8072
      @fakhrulislamfuad8072 11 หลายเดือนก่อน +1

      I'm a bit confused about the error.tsx page. Currently I've created a folder named [...rest] to handle all the invalid paths but as the error.tsx is client side component, it is showing me error. Do you have any sample project or can you update the existing with a not found page, please?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      @@fakhrulislamfuad8072 Sure I'll have that in mind for the part II of the video.

    • @fakhrulislamfuad8072
      @fakhrulislamfuad8072 11 หลายเดือนก่อน

      ​@@hamedbahramthanks a lot bro.. Hope that it comes very soon☺️☺️☺️

  • @TheIdo14
    @TheIdo14 ปีที่แล้ว +1

    Great video, thank you! the only downside is that when switching to a different language, the redirect can possibly cause data lost for unsaved data in the current page. how can I maybe add a warning modal or something similar to let the user know before actually redirecting?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      Perhaps you can implement it in the local toggle button before switching languages.

    • @TheIdo14
      @TheIdo14 ปีที่แล้ว

      I switched the Link buttons to a select input and used the onChange property and redirect() method from next/navigation. it does the trick. thank you man@@hamedbahram

  • @hesagoku6793
    @hesagoku6793 ปีที่แล้ว +1

    How about doing routing whitout that middleware file? I'm trying to build a static app with i18n, but for some reason I can't redirect the user to another file when i'ts trying to access the root file, so it gives the 404 error.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      Unfortunately static exports don't support middleware functions or internationalized routing!

    • @louisrogerguirika8281
      @louisrogerguirika8281 10 หลายเดือนก่อน

      what can we. do then to deploy static pages with this method @@hamedbahram

  • @Mcbuttifly
    @Mcbuttifly 10 หลายเดือนก่อน +1

    Great video! If you would like custom domains instead of lang code. How do you implement that?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      Thanks! You would then redirect to the correct domain or subdomain.

    • @Mcbuttifly
      @Mcbuttifly 9 หลายเดือนก่อน

      Hm i still dont understand where I change to domain or subdomain. @@hamedbahram

  • @josealvarezc97
    @josealvarezc97 6 หลายเดือนก่อน

    Is there a way this could work without any routing or domain change? I feel the ideal would be to just support different languages in any given page regardless of links or domains, like the Facebook website does it for example

    • @hamedbahram
      @hamedbahram  6 หลายเดือนก่อน

      Hmm 🤔 good question. I'd have to think about it.

  • @nabiabdelkader9833
    @nabiabdelkader9833 11 หลายเดือนก่อน +1

    how to use getDictionary in client component ?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Pass it as props or share it via react context.

    • @nabiabdelkader9833
      @nabiabdelkader9833 11 หลายเดือนก่อน +1

      thanks for your answer
      this is my way (It relies mainly on cookies so that the preferred language is sent in each request as it is known)
      import data from '@/app/core/dictionaries/en.json'
      export const DictionaryType = {...data} as const
      /**
      * React hook for managing language-related functionality in the application.
      * @function useLang
      * @returns {null | typeof DictionaryType} - The loaded language dictionary or null in case of an error.
      * @example
      * const MyComponent = () => {
      * const dictionary = useLang();
      *
      * // Use the dictionary in your component
      * if (dictionary) {
      * // Render content using the loaded dictionary
      * } else {
      * // Handle the case where the dictionary failed to load
      * }
      * };
      */
      const useLang = (): typeof DictionaryType | null => {
      const [dictionary, setDictionary] = useState(null);
      const loadDictionary = async () => {
      try {
      const langFromCookie = getCookie(config.langKey);
      let local: Locale = i18n.defaultLocale
      if (i18n.locales.includes(langFromCookie as Locale))
      local = langFromCookie as Locale
      const dictionary = await getDictionary(local)
      setDictionary(dictionary)
      } catch (error) {
      console.error('Error loading dictionary:', error);
      setDictionary(null);
      throw new LangException()
      }
      }
      useEffect(() => {
      loadDictionary()
      }, []);
      return dictionary;
      }
      export default useLang;@@hamedbahram

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      @@nabiabdelkader9833 Nice!

  • @louisrogerguirika8281
    @louisrogerguirika8281 10 หลายเดือนก่อน +1

    Hi guys , i followed the tutorial and i'am about to deploy my app. i face issue because i dont. have any index.html file but fr.html and en.html instead. i'd. like some help to fix my issue

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      This implementation requires a middleware function and won't work with static exports.

    • @louisrogerguirika8281
      @louisrogerguirika8281 10 หลายเดือนก่อน

      @@hamedbahram how could i deploy then ?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน

      @@louisrogerguirika8281 You can deploy it to Vercel or any other platform that supports NextJs.

  • @suhakarkhy639
    @suhakarkhy639 8 หลายเดือนก่อน

    Thank you

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      You're welcome 😊

  • @AhmedAlsabsab
    @AhmedAlsabsab 11 หลายเดือนก่อน +1

    Thanks for the good explaination... I'm still beginner in Localization... How can I use the dictionary in client components
    correctly my project code is like this toast.error(t('toast.error.users.invalid_invite'));
    using useTranslation hook

    • @AhmedAlsabsab
      @AhmedAlsabsab 11 หลายเดือนก่อน

      Is it better to pass the translations as props to client components?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Yes you can pass the translation as props or share it via React context.

  • @asemkakhi3284
    @asemkakhi3284 ปีที่แล้ว

    I have a question
    How do you add i18n to the not-found page?
    Because placing it under [lang] will make it not to work!!

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      I'd have to try that out. I should technically work even if it's inside a dynamic path like `[lang]`

    • @asemkakhi3284
      @asemkakhi3284 ปีที่แล้ว

      @@hamedbahram yes, you would be able to access it if you go to something like "/en/not-found"
      But if you try to go to "/en/1234" you will not see it, you will just see the default 404 black page

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      @@asemkakhi3284 I see 🤔 I'll test it out

    • @asemkakhi3284
      @asemkakhi3284 ปีที่แล้ว

      @@hamedbahram Also I learned that not-found component doesn't take any arguments, so how can you access the lang params in it??

  • @andreasWebDev
    @andreasWebDev 11 หลายเดือนก่อน +1

    That worked for me:
    "export default async function RootLayout({
    children,
    params,
    }: {
    children: React.ReactNode;
    params: { lang: Locale };
    }) {
    const dictionary = await getDictionary(params.lang);
    return (

    {children}

    );
    }"

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      Awesome!

  • @user-1ey38jsoowb
    @user-1ey38jsoowb ปีที่แล้ว +1

    Excellent, do you think you can share the notion notes?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      I'll publish it as a blog post on my site this week :)

  • @RoeiVeinberg
    @RoeiVeinberg 11 หลายเดือนก่อน +1

    There is no way to translate client components as well?

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน

      You can share context or pass down props to client components.

  • @zabialy2919
    @zabialy2919 ปีที่แล้ว +1

    Hi, it works like a charm. The only thing I am struggiling with is an error I get in the console which says that the dictionary[locale]() in the dictionary.ts file is not a function. Did anyone else encounter this error?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Hey! Thanks. Do you get the error if you clone my code? The error is probably because you're importing the 'getDictionaries' function in a client component

    • @zabialy2919
      @zabialy2919 ปีที่แล้ว +1

      @@hamedbahram Thanks for the response! I don't know what the cause was, but after removing node_modules and installing everything again I don't get any errors (that's why I was wondering as my code was 1:1 like yours) :)

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      @@zabialy2919 Sweet!

  • @SamuelAlegreCastro
    @SamuelAlegreCastro 10 หลายเดือนก่อน +1

    Hi Hamed, thank you so much for your videos! I'm having some trouble trying to set span tags within text from dictionaries. Is there any way to implement them? Thanks in advance 🙏🏼

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน +1

      Anytime! That's a bit tricky to do 🤔

    • @SamuelAlegreCastro
      @SamuelAlegreCastro 10 หลายเดือนก่อน +1

      Yeah, that's what I think too 😅 But if I need to store, for instance, a blog post entry that has bold, italics... What would be the proper way to do it?

    • @hamedbahram
      @hamedbahram  10 หลายเดือนก่อน +1

      @@SamuelAlegreCastro probably a CMS that support internationalizaiton would be your best bet.

  • @temtechie
    @temtechie 11 หลายเดือนก่อน +1

    @Hamed Bahram
    what about in a situation where a developer uses 'use client' flag in the rootLayout ,
    how do one intend to use
    export async function generateStaticParams() {
    return i18n.locales.map(locale => ({ lang: locale }))
    }
    in this cas, because sure 'use client' is needed to use useState in the RootLayout if there is need for it

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      Instead of adding the `use client` to the root layout, you should move the interactive logic that requires React state to a client component down in the tree.

  • @vinodhm8452
    @vinodhm8452 ปีที่แล้ว +1

    Nice explanation !! I have a doubt ,if we add the language inside our project in json file is it affect the SEO ? ,for my current project SEO is very important is it affect indexing the page from google crawler when we change the language ?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +2

      Nah not really the JSON file remains on the server, and you're pages would be content on the client. You can also use the `generateStaticParams` function to statically build your pages at build time.

    • @vinodhm8452
      @vinodhm8452 ปีที่แล้ว +1

      @@hamedbahram Thanks

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      @@vinodhm8452 Anytime!