-
Notifications
You must be signed in to change notification settings - Fork 3
Cannot read property 'toResolveHierarchy' of undefined #9
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
Comments
@brettdewoody |
I am also seeing this, but I'm using
I'm also using the new config files not the old |
...just kidding. I got it working client side, see below: preview.js: import { addParameters, addDecorator } from '@storybook/react';
import { withI18n } from 'storybook-addon-i18n';
import i18n from '../src/i18n';
import { I18nextProvider } from 'react-i18next';
addParameters({
i18n: {
provider: I18nProviderWrapper,
providerProps: {
i18n
},
supportedLocales: [ 'en' ],
},
});
addDecorator(withI18n); ../src/i18n: import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import * as en from './locales/en'; // these are the translated files
i18n.use(initReactI18next).init({
// for all options read: https://www.i18next.com/overview/configuration-options
fallbackLng: 'en',
languages: [ 'en' ],
debug: false,
lng: 'en',
returnObjectTrees: true,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
resources: {
en,
},
});
export default i18n; |
@ldeveber Thanks for your reply. |
I'm using
storybook-addon-i18n
and have a conditional i18next configuration depending on an environment variable. In Storybook I bundle the translation files. In my actual web app I use thei18next-xhr-backend
to load the translations from my server.To do this I define a
STORYBOOK_
env variable when runningnpm run storybook
, and in the configuration ofi18n
conditionally use XHR, or import the translations as resources. Like this:This works until I refresh Storybook. When I do it throws the following error:
If I switch to a different story everything starts working again.
I see some items in the changelog related to fixing this issue of
toResolveHierarchy
returningundefined
, but on much earlier versions if i18n.Package versions
"i18next": "^19.0.0",
"i18next-browser-languagedetector": "^4.0.1",
"i18next-xhr-backend": "^3.2.2",
"react-i18next": "^11.0.1",
"storybook-addon-i18n": "^5.1.11",
"@storybook/react": "^5.2.5",
The text was updated successfully, but these errors were encountered: