@simoncrypta Thank you for taking time to reply.
I have just now tried the --force option to reconfigure, no dice…
… but it did change the storyboook.preview.js
Now I am not sure if this is because I created that file or if that’s something that 2.1 introduced.
Should I be installing the storybook-react-i18next
addon manually?
I’ll explain what I did:
I installed with yarn workspace web add -D storybook-react-i18next
Probably I added packages from i18next README:
yarn add i18next react-i18next i18next-browser-languagedetector i18next-http-backend
Here’s part of package.json:
"dependencies": {
"@redwoodjs/forms": "^2.1.0",
"@redwoodjs/router": "^2.1.0",
"@redwoodjs/web": "^2.1.0",
"i18n": "^0.15.0",
"i18next": "^21.8.14",
"i18next-browser-languagedetector": "^6.1.4",
"prop-types": "15.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "^11.18.1"
},
"devDependencies": {
"@storybook/addons": "^6.5.9",
"@storybook/theming": "^6.5.9",
"autoprefixer": "^10.4.7",
"i18next-http-backend": "^1.4.1",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"storybook-react-i18next": "^1.1.2",
"tailwindcss": "^3.1.4"
}
Configured the addon in: storybook.config.js
module.exports = {
/**
* This line adds all of Storybook's essential addons.
*
* @see {@link https://storybook.js.org/addons/tag/essentials}
*/
addons: ['storybook-react-i18next'],
};
It did change the
But now when loading Storybook it “hangs” with error (the file is present):
Uncaught Error: Cannot find module 'web/src/i18n'
at webpackMissingModule (RefreshUtils.js:271:1)
at ./config/storybook.preview.js (RefreshUtils.js:271:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at ../node_modules/@redwoodjs/testing/config/storybook/preview.js (preview.js:25:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at ../node_modules/@redwoodjs/testing/config/storybook/preview.js-generated-config-entry.js (preview.js:28:1)
VM417:1 POST http://localhost:7910/runtime-error 404 (Not Found)
(anonymous) @ VM417:1
onerror @ iframe.html?viewMode=story&id=*:329
error (async)
(anonymous) @ iframe.html?viewMode=story&id=*:323
I also created a file in web/config/i18next
:
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';
const ns = ['common'];
const supportedLngs = ['pl', 'en'];
i18n
.use(initReactI18next)
.use(LanguageDetector)
.use(Backend)
.init({
debug: false,
lng: 'pl',
fallbackLng: 'pl',
defaultNS: 'common',
ns,
interpolation: { escapeValue: false },
react: { useSuspense: false },
supportedLngs,
backend: {
loadPath: '../src/locales/{{lng}}.json',
},
});
export default i18n;
but it is not referenced by any file and config from i18n.js is used.
What is curious Backend
is recognized in i18next
file but not in i18n
Any suggestions are very welcome.
PS. I should add that Locales work properly in frontend with current setup.