Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback Locale with App Router #364

Open
zfm-lucaschultz opened this issue Feb 20, 2024 · 3 comments
Open

Fallback Locale with App Router #364

zfm-lucaschultz opened this issue Feb 20, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@zfm-lucaschultz
Copy link

Is your feature request related to a problem? Please describe.
I would like to add a fallback locale when using the I18nProviderClient with the app router. The documentation only mentions a fallbackLocale prop for the I18nProvider with the page router. While there is a fallbackLocale config option for createI18nClient and createI18nServer, I'm either using it incorrectly or it doesn't work.

'use client';

import { createI18nClient } from 'next-international/client';

export const {
  useI18n,
  useScopedI18n,
  I18nProviderClient,
  useCurrentLocale,
  useChangeLocale,
} = createI18nClient(
  {
    de: () => import('./locales/de'),
    en: () => import('./locales/en'),
  },
  {
    fallbackLocale: {
      en: 'de',
    },
  },
);

Either way, it might be good to add documentation for this.

Describe the solution you'd like
Add a fallback locale when using the app router and/or add documentation for it.

Describe alternatives you've considered
I had a look at the code, but it wasn't immediately clear how to use the fallback locale.

Additional context
None.

@zfm-lucaschultz zfm-lucaschultz added the enhancement New feature or request label Feb 20, 2024
@QuiiBz
Copy link
Owner

QuiiBz commented Feb 20, 2024

Indeed the documentation is missing this option, but we'll update and improve it with #359

Looking at your example code, it looks incorrect. You have to pass a locale object, see the example:

@zfm-lucaschultz
Copy link
Author

@QuiiBzI figured out how to use the fallback correctly, but thank you for the quick clarification. 👍 Still, adding documentation for this would be nice.

@madfcat
Copy link

madfcat commented Nov 18, 2024

+1 for a better documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants