QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.2k stars 54 forks source link

override locale for certain components #307

Closed abellaismail7 closed 7 months ago

abellaismail7 commented 7 months ago

I wonder if we can override language for a component rather than the whole page. I thought about have nest I18nProvider but didn't work is that possible?

what I tried and didn't work.

<I18nProvider locale={globalLocale}>
  ....
  <I18nProvider locale={localLocal}>
      <MyComponent />
  </I18nProvider>
  ....
</I18nProvider>

Current behavior: inner I18nProvider has no effect at all.

Expected behavior: I expected that nested provider will override it parent.

QuiiBz commented 7 months ago

This feature isn't supported. I'm curious why you'll want to have some parts of the page use another locale?

abellaismail7 commented 7 months ago

I appreciate your answer and your library. I will continue using despite that.

I have a dashboard where you can write multi languages content so I don't want to change the whole page locale when the admin pick another locale for the content.

<dashboard locale={userPrefrence}>
     <Editor locale={contentLanguage} />
</dashboard>

When I use unified language it looks ugly in RTL vs LTR languages.