Removing the Default Locale | Internationalization in NextJs 14

  Рет қаралды 12,537

Hamed Bahram

Hamed Bahram

Күн бұрын

Пікірлер: 171
@andresgiovannicanasrodrigu7301
@andresgiovannicanasrodrigu7301 8 ай бұрын
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 8 ай бұрын
Thank you! I'm glad you found the video helpful. And yes you can store user language preference in db.
@heysahilsingh
@heysahilsingh Жыл бұрын
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 Жыл бұрын
Welcome onboard! I'm glad to hear that! Thanks for the feedback, I'll try 😅
@amelianceskymusic
@amelianceskymusic Жыл бұрын
It's easy to speed up the video in the KZbin player itself, but not so easy to slow it down while maintaining decent quality
@hamedbahram
@hamedbahram Жыл бұрын
@@amelianceskymusic That's right :)
@Sorkstryparen
@Sorkstryparen 10 ай бұрын
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 10 ай бұрын
I appreciate that. Thanks for the suggestion.
@SoufianeElkarnoubi
@SoufianeElkarnoubi 11 ай бұрын
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 11 ай бұрын
You're welcome, Soufiane! I'm glad to hear it helped.
@KaMZaTa
@KaMZaTa Жыл бұрын
Hi Hamed! What about url translation? That's really important speaking about SEO! You never mentioned it!
@hamedbahram
@hamedbahram Жыл бұрын
You're right that is important for SEO. I'll try that in future videos
@KaMZaTa
@KaMZaTa Жыл бұрын
@@hamedbahram That would be great! Thanks!
@hamedbahram
@hamedbahram 10 ай бұрын
@@den9943 How about using a translation object to map URLs and redirect in the middleware function?
@arvin6
@arvin6 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
​@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 11 ай бұрын
@@arvin6 No worries man! Glad to help.
@arvin6
@arvin6 11 ай бұрын
@@hamedbahram 🙏🏻
@kursatpolatci
@kursatpolatci 5 ай бұрын
Thank you so much. i had searched so much this subject. but i didn't find anthing. finally i made it thanks
@hamedbahram
@hamedbahram 5 ай бұрын
You're welcome! Glad to hear that.
@udhay2909
@udhay2909 Жыл бұрын
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 Жыл бұрын
Glad to hear that Udhay! Absolutely I'll cover socket in NextJs. Thanks for the suggestion.
@averelgr
@averelgr 2 ай бұрын
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 Ай бұрын
Isn't what I showed in the video the solution you're looking for?
@averelgr
@averelgr Ай бұрын
@@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.
@EA-nr9hc
@EA-nr9hc 7 ай бұрын
Thank you so much! You saved me after hours and hours of googling
@hamedbahram
@hamedbahram 7 ай бұрын
Glad I could help!
@iantolmay1902
@iantolmay1902 4 ай бұрын
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 4 ай бұрын
I'm not sure how removing the default locale would affect the seo, not an expert in that domain.
@amxwarestudios
@amxwarestudios 9 ай бұрын
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 9 ай бұрын
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.
@ZacharyStout-o5n
@ZacharyStout-o5n 10 ай бұрын
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 10 ай бұрын
I'll probably make a video on that.
@ZacharyStout-o5n
@ZacharyStout-o5n 10 ай бұрын
@@hamedbahram 😍😍😍
@Kruspe616
@Kruspe616 8 ай бұрын
​@@hamedbahram Are there still plans to make that?
@EduardoSotoTi
@EduardoSotoTi 11 ай бұрын
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 11 ай бұрын
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
@BestinaTV
@BestinaTV 3 ай бұрын
دمت گرم آفا حامد عزیز عالی بود💖
@hamedbahram
@hamedbahram 3 ай бұрын
Eraadat 🫡
@alexeysmirnov9288
@alexeysmirnov9288 8 ай бұрын
Thank Hamed for this useful video! Just in time)
@hamedbahram
@hamedbahram 8 ай бұрын
Glad it was helpful!
@fakhrulislamfuad8072
@fakhrulislamfuad8072 Жыл бұрын
This video was quite informative.. but bro.. please upload your next video on translating the not-found page efficiently
@hamedbahram
@hamedbahram Жыл бұрын
Thanks! I don't know what's with this, but I keep forgetting 😭
@fakhrulislamfuad8072
@fakhrulislamfuad8072 Жыл бұрын
@@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 Жыл бұрын
@@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 Жыл бұрын
@@hamedbahram thank you so much bro..
@juanferrer5885
@juanferrer5885 Жыл бұрын
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 Жыл бұрын
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.
@mother_chucker12
@mother_chucker12 4 ай бұрын
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 4 ай бұрын
My pleasure! It would be a very similar concept to what we've done here.
@mother_chucker12
@mother_chucker12 4 ай бұрын
@@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
@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 2 ай бұрын
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.
@jarekch.3659
@jarekch.3659 7 ай бұрын
Now we have /about and /en/about? Two urls for the same site? Is that correct for SEO?
@hamedbahram
@hamedbahram 7 ай бұрын
well /en/about redirects to /about
@ceza121121
@ceza121121 8 ай бұрын
This is good but how we can use interpolation ?
@hamedbahram
@hamedbahram 8 ай бұрын
I'm not sure, I think you'd have to use a third-party library for that.
@sonakissonaki
@sonakissonaki 7 ай бұрын
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 7 ай бұрын
Hmm 🤔 let me check this...
@whisky961
@whisky961 5 ай бұрын
@@hamedbahram have you checked yet? it's very annoying. I am trynna debug it myself, nothing so far.
@d4rzk252
@d4rzk252 4 ай бұрын
@@whisky961did u fix this? I have same problem…
@amelianceskymusic
@amelianceskymusic Жыл бұрын
Thank you. Next question: how to provide the dictionary without props drilling=)))
@hamedbahram
@hamedbahram Жыл бұрын
You can share via React context or any other global state management for that matter.
@amelianceskymusic
@amelianceskymusic Жыл бұрын
@@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 Жыл бұрын
@@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 :)
@arefpasha
@arefpasha 10 ай бұрын
thank mr hamed for this useful video
@hamedbahram
@hamedbahram 10 ай бұрын
Glad you found it useful!
@АлександрЛебединский-э4ц
@АлександрЛебединский-э4ц 6 күн бұрын
ok, but what about client component? we can't load dictionary because 'server-only'! How should I localize client component?
@sp4mdev
@sp4mdev 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
​@@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 11 ай бұрын
@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 11 ай бұрын
@@sp4mdev yup!
@zakidzz
@zakidzz 11 ай бұрын
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 11 ай бұрын
Only pass in the specific translation to your client components or share the dictionary via a global state management.
@naleon-yr5ss
@naleon-yr5ss 7 ай бұрын
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 7 ай бұрын
Not sure! I haven't had this problem on my deployed version.
@KeepItFresh02
@KeepItFresh02 3 ай бұрын
I am having the same problem. local works fine, but prod is abit off. both have same configurations.
@wakibtz7134
@wakibtz7134 10 ай бұрын
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 10 ай бұрын
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 10 ай бұрын
@@hamedbahram Yo man thank you so much!
@hamedbahram
@hamedbahram 10 ай бұрын
@@wakibtz7134 anytime!
@liviabellomi
@liviabellomi 10 ай бұрын
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 10 ай бұрын
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 10 ай бұрын
Thanks a lot! 😊
@ryanpratama14
@ryanpratama14 11 ай бұрын
How about making the browser remember the user's last preferred language?
@hamedbahram
@hamedbahram 11 ай бұрын
Yeah you can write the locale to the local storage but you won't be able to read that inside the middleware.
@nicolasaraujo4757
@nicolasaraujo4757 8 ай бұрын
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 8 ай бұрын
I see... I'll have a look at it.
@alexla1337
@alexla1337 6 ай бұрын
@@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.
@amirfarahani6580
@amirfarahani6580 10 ай бұрын
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 10 ай бұрын
Not sure why that's happening. It doesn't happen on my end. Check here → next-i18n-ten.vercel.app/
@amirfarahani6580
@amirfarahani6580 9 ай бұрын
@@hamedbahram i use basePath in next.Config.js Can this be the reason for this?
@luisgerardocontreras6612
@luisgerardocontreras6612 Жыл бұрын
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 Жыл бұрын
Look inside your js.config or ts.config if using TypeScript and see what import alias you're using.
@ps__9979
@ps__9979 Жыл бұрын
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 Жыл бұрын
You need to exclude your `images` folder from the config matcher.
@ps__9979
@ps__9979 Жыл бұрын
@@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 Жыл бұрын
@@ps__9979 My pleasure! Thanks for the update.
@Foused87
@Foused87 Жыл бұрын
​@@hamedbahramhow exactly can I do that?
@hamedbahram
@hamedbahram Жыл бұрын
@@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).*)'] } ```
@kakun7238
@kakun7238 9 ай бұрын
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 9 ай бұрын
Hmm 🤔 Not sure what that error is, It's working fine on my end.
@kakun7238
@kakun7238 9 ай бұрын
I found it bc I had put ne_NP as a locale
@amelianceskymusic
@amelianceskymusic Жыл бұрын
Do I understand correctly that when changing the language, we lose the search params in the address bar?
@amelianceskymusic
@amelianceskymusic Жыл бұрын
I use const searchParams = useSearchParams(); and add its to path `${path}?${searchParams }`
@hamedbahram
@hamedbahram Жыл бұрын
Hmm 🤔 good question! we might need an update here...
@TheSummerPro
@TheSummerPro 10 ай бұрын
Grazie mille!!
@hamedbahram
@hamedbahram 10 ай бұрын
Piacere mio!
@nikmat
@nikmat 11 ай бұрын
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 11 ай бұрын
Can you expand on that... Do you mean it's not removing the default locale?
@nikmat
@nikmat 11 ай бұрын
@@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 10 ай бұрын
​@@hamedbahramyes I have the same problem((( Help please!
@irfanulislamjishan4416
@irfanulislamjishan4416 Жыл бұрын
Great video. loved it.
@hamedbahram
@hamedbahram Жыл бұрын
Thanks.
@krisporovarde9370
@krisporovarde9370 10 ай бұрын
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 10 ай бұрын
Which one of the pages are not indexed?
@krisporovarde9370
@krisporovarde9370 10 ай бұрын
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
@denissirenko309
@denissirenko309 11 ай бұрын
Thank you very much !!!
@hamedbahram
@hamedbahram 11 ай бұрын
You are welcome!
@Foused87
@Foused87 11 ай бұрын
How can I use that with zod for custom errors based on user localization?
@hamedbahram
@hamedbahram 11 ай бұрын
🤔 Good question! I'm not sure.
@Foused87
@Foused87 Жыл бұрын
veeeery helpful, thanks
@hamedbahram
@hamedbahram Жыл бұрын
You're welcome :) Glad it was helpful!
@kazinafizanam9397
@kazinafizanam9397 9 ай бұрын
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 9 ай бұрын
You have to put your images inside an `image` folder inside the public folder.
@kazinafizanam9397
@kazinafizanam9397 9 ай бұрын
@@hamedbahram they are.. but still not show up if I do /images/home/banner.png for example...
@hamedbahram
@hamedbahram 9 ай бұрын
@@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 9 ай бұрын
@@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 9 ай бұрын
@@kazinafizanam9397 If you don't know how to add a folder to the config matcher don't blame it on the code.
@pauloalves2840
@pauloalves2840 Ай бұрын
i refreshed the page and my comment disappeared? can you see it?
@hamedbahram
@hamedbahram Ай бұрын
I can see this comment 😁
@quizproject-n1k
@quizproject-n1k 8 ай бұрын
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 8 ай бұрын
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 8 ай бұрын
@@hamedbahram i thought "use server" is replace for server-only because in that moment intl doesnt support use server...
@wakibtz7134
@wakibtz7134 9 ай бұрын
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 9 ай бұрын
What happens to your search params when removing the default locale?
@wakibtz7134
@wakibtz7134 9 ай бұрын
@@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 :)
@szymon2806
@szymon2806 2 ай бұрын
It doesn't work... I can access the homepage with / and with /en.
@hamedbahram
@hamedbahram 2 ай бұрын
Not sure what you mean by it doesn't work!
@askarzhaanbaev5834
@askarzhaanbaev5834 Жыл бұрын
Could u please build this project? it still will work? maybe with output export.
@hamedbahram
@hamedbahram Жыл бұрын
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
@Foused87
@Foused87 Жыл бұрын
All files from /public folder can't load. How can I fix that?
@hamedbahram
@hamedbahram Жыл бұрын
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).*)'] } ```
@d4rzk252
@d4rzk252 4 ай бұрын
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 4 ай бұрын
I'll have a look!
@d4rzk252
@d4rzk252 4 ай бұрын
@@hamedbahram Thanks.. If you can't reproduce it, I'll make a video of what it does..
@hamedbahram
@hamedbahram 4 ай бұрын
@@d4rzk252 sure that can be helpful!
@d4rzk252
@d4rzk252 4 ай бұрын
@@hamedbahram I cannot post a link here
@d4rzk252
@d4rzk252 4 ай бұрын
@@hamedbahram I sent u the video via your portfolio form
@DevStreamJs
@DevStreamJs 8 ай бұрын
but what if I fetch data from API ?
@hamedbahram
@hamedbahram 8 ай бұрын
What do you mean by that?
@DevStreamJs
@DevStreamJs 8 ай бұрын
@@hamedbahram i mean i will receive the whole translation json from an API call. Not static JSON data
@hamedbahram
@hamedbahram 8 ай бұрын
@@DevStreamJs Yeah that's fine too, you can fetch the data from a remote API.
@DevStreamJs
@DevStreamJs 8 ай бұрын
could you please make a video for remote API 🙏​@@hamedbahram
@mzpizote
@mzpizote 7 ай бұрын
Props drilling with lang looks very bad for me 😒
@hamedbahram
@hamedbahram 7 ай бұрын
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 → kzbin.info/www/bejne/pX7ZiGZ3lK6Fqbs
@vincentbobinski5564
@vincentbobinski5564 11 ай бұрын
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 11 ай бұрын
It's definitely not as straight forward as adding i18n to the `pages` router.
@fungau1243
@fungau1243 11 ай бұрын
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 11 ай бұрын
You can clone my code (link in the video description) and compare your code to mine and see what you're doing differently.
@joaomaia9140
@joaomaia9140 8 ай бұрын
Thx, how to know what is the current lang, on the lang switcher? locale !== pathName.split('/')[1], but is not working
@hamedbahram
@hamedbahram 8 ай бұрын
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.
Parallel Routes in NextJs 14
21:27
Hamed Bahram
Рет қаралды 34 М.
Global State Management in NextJs 14 Using Zustand
51:17
Hamed Bahram
Рет қаралды 33 М.
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 42 МЛН
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 47 МЛН
This Game Is Wild...
00:19
MrBeast
Рет қаралды 130 МЛН
Internationalization in NextJs 14 with Next-Intl | i18n
28:40
Next.js 15 Is Here (Vercel Ship Breakdown)
19:34
Theo - t3․gg
Рет қаралды 103 М.
Chain Multiple Middleware Functions in NextJs 13
19:47
Hamed Bahram
Рет қаралды 15 М.
Why I Cant Stand IDE's After Using VIM | Prime Reacts
17:51
ThePrimeTime
Рет қаралды 375 М.