Skip to content

Commit 4f339ed

Browse files
justin808claude
andcommitted
Fix SSR error by adding both named and default exports for translations
The server-side rendering was failing because SWC/Webpack needs both the named export and default export for proper module interoperability. Changes: - Restored both exports in translations.js: export { translations } + export default - Renamed default import to 'translationsData' to avoid ESLint import/no-named-as-default error - Updated all three files that import translations to use the new name This fixes the "Cannot read properties of undefined (reading 'en')" error in server-side rendering. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 53e3945 commit 4f339ed

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

client/app/bundles/comments/components/SimpleCommentScreen/ror_components/SimpleCommentScreen.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IntlProvider, injectIntl } from 'react-intl';
88
import BaseComponent from 'libs/components/BaseComponent';
99
import SelectLanguage from 'libs/i18n/selectLanguage';
1010
import { defaultMessages, defaultLocale } from 'libs/i18n/default';
11-
import translations from 'libs/i18n/translations';
11+
import translationsData from 'libs/i18n/translations';
1212

1313
import CommentForm from '../../CommentBox/CommentForm/CommentForm';
1414
import CommentList from '../../CommentBox/CommentList/CommentList';
@@ -123,7 +123,7 @@ export default class I18nWrapper extends BaseComponent {
123123

124124
render() {
125125
const { locale } = this.state;
126-
const messages = translations[locale];
126+
const messages = translationsData[locale];
127127
const InjectedSimpleCommentScreen = injectIntl(SimpleCommentScreen);
128128

129129
return (

client/app/bundles/comments/containers/NonRouterCommentsContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { bindActionCreators } from 'redux';
66
import Intl from 'intl';
77
import { IntlProvider } from 'react-intl';
88
import BaseComponent from '../../../libs/components/BaseComponent.jsx';
9-
import translations from '../../../libs/i18n/translations';
9+
import translationsData from '../../../libs/i18n/translations';
1010
import { defaultLocale } from '../../../libs/i18n/default';
1111

1212
import CommentScreen from '../components/CommentScreen/CommentScreen.jsx';
@@ -29,7 +29,7 @@ class NonRouterCommentsContainer extends BaseComponent {
2929
const { dispatch, data } = this.props;
3030
const actions = bindActionCreators(commentsActionCreators, dispatch);
3131
const locale = data.get('locale') || defaultLocale;
32-
const messages = translations[locale];
32+
const messages = translationsData[locale];
3333

3434
return (
3535
<IntlProvider locale={locale} key={locale} messages={messages}>

client/app/bundles/comments/containers/RouterCommentsContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { bindActionCreators } from 'redux';
66
import { IntlProvider } from 'react-intl';
77
import Intl from 'intl';
88
import { defaultLocale } from '../../../libs/i18n/default';
9-
import translations from '../../../libs/i18n/translations';
9+
import translationsData from '../../../libs/i18n/translations';
1010

1111
import CommentScreen from '../components/CommentScreen/CommentScreen.jsx';
1212
import * as commentsActionCreators from '../actions/commentsActionCreators';
@@ -24,7 +24,7 @@ function RouterCommentsContainer(props) {
2424
const location = useLocation();
2525
const locationState = location.state;
2626
const locale = data.get('locale') || defaultLocale;
27-
const messages = translations[locale];
27+
const messages = translationsData[locale];
2828

2929
return (
3030
<IntlProvider locale={locale} key={locale} messages={messages}>

client/app/libs/i18n/translations.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ const translations = {
3636
},
3737
};
3838

39+
export { translations };
3940
export default translations;

0 commit comments

Comments
 (0)