Skip to content

Commit 5371f79

Browse files
Merge pull request #50 from rajat-ws/feat/add-lingui
feat: migrate react-intl to lingui
2 parents 54dc925 + 9d6783e commit 5371f79

File tree

47 files changed

+1071
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1071
-442
lines changed

.storybook/config.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { configure } from '@storybook/react';
2-
import '@formatjs/intl-relativetimeformat/polyfill';
3-
import '@formatjs/intl-relativetimeformat/locale-data/en';
41
import React from 'react';
2+
import { configure } from '@storybook/react';
53
import { addDecorator } from '@storybook/react';
64
import { withKnobs } from '@storybook/addon-knobs';
75
import StoryRouter from 'storybook-router';
86
import { withSmartKnobs } from 'storybook-addon-smart-knobs';
97
import { setIntlConfig, withIntl } from 'storybook-addon-intl';
10-
// import enLocaleData from 'react-intl/locale-data/en';
11-
import { translationMessages, appLocales, DEFAULT_LOCALE } from '../app/i18n.js';
8+
import { translationMessages, appLocales, DEFAULT_LOCALE } from '../app/i18n.ts';
129

1310
Object.values = (obj) => Object.keys(obj).map((key) => obj[key]);
1411

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ An enterprise react template application showcasing - Testing strategies, Global
118118

119119
- [app/containers/HomeContainer/index.tsx](app/containers/HomeContainer/index.tsx)
120120

121-
## Localization using react-intl
121+
## Localization using Lingui
122122

123-
- Translations using [React Intl](https://github.com/formatjs/react-intl)
123+
- Translations using [Lingui](https://github.com/lingui/js-lingui)
124124

125125
Take a look at the following files
126126

app/components/Clickable/tests/__snapshots__/index.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`<Clickable /> component tests should render and match the snapshot 1`] = `
44
<body>
55
<div>
6+
67
<div
78
class="Clickable__StyledClickable-sc-1vn3tbu-0 mgTtM"
89
data-testid="clickable"
@@ -14,6 +15,7 @@ exports[`<Clickable /> component tests should render and match the snapshot 1`]
1415
List of launches
1516
</p>
1617
</div>
18+
1719
</div>
1820
</body>
1921
`;

app/components/ErrorBoundary/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import React, { PropsWithChildren } from 'react';
8-
import { translate } from '@components/IntlGlobalProvider/index';
8+
import { translate } from '@app/utils';
99

1010
interface ErrorState {
1111
hasError: boolean;

app/components/ErrorHandler/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const CustomCard = styled(Card)`
1313

1414
interface ErrorHandlerTypes {
1515
loading: boolean;
16-
launchListError?: string;
16+
launchListError: string;
1717
}
1818

1919
export function ErrorHandler({ loading, launchListError }: ErrorHandlerTypes) {
2020
if (!loading) {
2121
return (
2222
<If condition={launchListError} otherwise={<T data-testid="default-message" id={launchListError} />}>
2323
<CustomCard data-testid="error-card">
24-
<T data-testid="error-message" text={launchListError} />
24+
<T data-testid="error-message" text={launchListError} id={launchListError} />
2525
</CustomCard>
2626
</If>
2727
);

app/components/ErrorHandler/tests/__snapshots__/index.test.js.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`<ErrorHandler /> should render and match the snapshot 1`] = `
44
<body>
55
<div>
6+
67
<div
78
class="ant-card ant-card-bordered ErrorHandler__CustomCard-sc-1rh55w4-0 eOLbNC"
89
data-testid="error-card"
@@ -14,10 +15,11 @@ exports[`<ErrorHandler /> should render and match the snapshot 1`] = `
1415
class="T__StyledText-znbtqz-0 TmgHn"
1516
data-testid="error-message"
1617
>
17-
something_went_wrong
18+
Something went wrong
1819
</p>
1920
</div>
2021
</div>
22+
2123
</div>
2224
</body>
2325
`;

app/components/Header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const StyledHeader = styled(Layout.Header)`
1818
height: ${(props) => props.theme.headerHeight};
1919
align-items: center;
2020
justify-content: center;
21-
background-color: ${colors.primary};
21+
background-color: ${colors.lightGreen};
2222
gap: 1rem;
2323
${media.lessThan('mobile')`
2424
padding-left: ${(props) => props.theme.sidebarWidth}

app/components/Header/tests/__snapshots__/index.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`<Header /> should render and match the snapshot 1`] = `
44
<body>
55
<div>
66
<header
7-
class="ant-layout-header Header__StyledHeader-sc-1oujkb8-0 gUdnlM"
7+
class="ant-layout-header Header__StyledHeader-sc-1oujkb8-0 iCzSdw"
88
data-testid="header"
99
>
1010
<a

app/components/IntlGlobalProvider/index.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/components/IntlGlobalProvider/tests/index.test.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)