Skip to content

Commit

Permalink
fix: i18n namespaces with getServerSideProps
Browse files Browse the repository at this point in the history
  • Loading branch information
mateus4k committed Jul 18, 2020
1 parent 0c3b486 commit 45bf3fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/web/pages/[technology]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ export const getServerSideProps = async ({ query, res }) => {

return {
props: {
namespacesRequired: ['common', 'search', 'card', 'helper'],
statusCode: res.statusCode,
statusCode: res.statusCode || 200,
technology,
},
};
};

Technology.defaultProps = {
// eslint-disable-next-line react/default-props-match-prop-types
i18nNamespaces: ['home-page'],
};

Technology.propTypes = {
technology: PropTypes.shape().isRequired,
statusCode: PropTypes.number.isRequired,
Expand Down
14 changes: 12 additions & 2 deletions packages/web/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ export class SabiaApp extends App {
appContext.ctx.user = user;

const appProps = await App.getInitialProps(appContext);

return { ...appProps, user };
const { defaultProps } = appContext.Component;

return {
...appProps,
pageProps: {
namespacesRequired: [
...(appProps.pageProps.namespacesRequired || []),
...(defaultProps?.i18nNamespaces || []),
],
},
user,
};
}

render() {
Expand Down

0 comments on commit 45bf3fa

Please sign in to comment.