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

fix: storybook can use next-i18next in webpack@5 setup #44

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

natterstefan
Copy link
Owner

@natterstefan natterstefan commented Aug 3, 2021

TASK

Issues

Tasks

next-i18next

webpack@5 vs. webpack@4

  • I tried both and neither of them worked. So it does not seem to be related to webpack.

Screenshot of the issue

This is the warning I am struggling with: react-i18next:: You will need to pass in an i18next instance by using initReactI18next. Because it does not load translations when I get this error...

image

@natterstefan natterstefan added the bug Something isn't working label Aug 3, 2021
@natterstefan natterstefan self-assigned this Aug 3, 2021
@vercel
Copy link

vercel bot commented Aug 3, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/natterstefan/nextjs-template/CsXkLGWy49Sj5Ckfa3rt4tg5wvMk
✅ Preview: https://nextjs-template-git-fix-storybook-i18next-webpack5-natterstefan.vercel.app

@natterstefan natterstefan changed the title chore: updated all deps, attempt to fix i18n in storybook feat: attempt setting up Storybook, i18n-next and webpack@5 Aug 3, 2021
@natterstefan natterstefan changed the title feat: attempt setting up Storybook, i18n-next and webpack@5 feat: attempt setting up Storybook, next-i18next and webpack@5 Aug 3, 2021
Base automatically changed from chore/202107-des-update to main August 5, 2021 17:48
@natterstefan natterstefan force-pushed the fix/storybook-i18next-webpack5 branch from 6f95bee to a6aa380 Compare August 5, 2021 17:50
@natterstefan natterstefan changed the title feat: attempt setting up Storybook, next-i18next and webpack@5 fix: storybook can use next-i18next in webpack@5 setup Aug 5, 2021
@natterstefan
Copy link
Owner Author

natterstefan commented Nov 24, 2021

Status Update for anyone reading this

Storybook i18n Setup

There was also an update in the docs of next-i18next making me aware of the ns property in the i18n config: https://github.com/locize/next-i18next-locize/blob/3d2c4af7511a58e093073755283f4d092bcf5676/next-i18next.config.js#L17. Can this be helpful? It's also used in the linked PR above.

Vercel Deployment Issue

I also experienced other issues in that Vercel is not able to find the translation files when deploying Storybook with next-i18next. See the following issues:

Solution (hack IMHO)

/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path')

/**
 * HACK: make sure Vercel includes those files
 */
if (typeof window === 'undefined') {
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  const _files = path.resolve('./public/locales')
}

/**
 * Docs:
 * @see https://nextjs.org/docs/advanced-features/i18n-routing
 * @type {import('next').NextConfig["i18n"]}
 */
const i18n = {
  defaultLocale: 'en',
  locales: ['en', 'de'],
  // without the need to add this line
  // localePath: path.resolve('./public/locales'),
}

module.exports = {
  i18n,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Storybook related to next-i18next setup
1 participant