Skip to content

Commit 9558c4c

Browse files
committed
add support for i18n
1 parent 35d7a16 commit 9558c4c

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import i18n from "i18next";
22
import { initReactI18next } from "react-i18next";
33

4+
const ns = ["common"];
5+
const supportedLngs = ["en", "fr"];
6+
const resources = ns.reduce((acc, n) => {
7+
supportedLngs.forEach((lng) => {
8+
if (!acc[lng]) acc[lng] = {};
9+
acc[lng] = {
10+
...acc[lng],
11+
[n]: require(`../../web/public/static/locales/${lng}/${n}.json`),
12+
};
13+
});
14+
return acc;
15+
}, {});
16+
417
i18n.use(initReactI18next).init({
5-
resources: [],
618
debug: true,
19+
fallbackLng: "en",
20+
defaultNS: "common",
21+
ns,
22+
interpolation: {
23+
escapeValue: false,
24+
},
25+
react: { useSuspense: true },
26+
resources,
727
});
828

929
export default i18n;

apps/storybook/.storybook/preview.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ export const parameters = {
2121
push() {},
2222
Provider: AppRouterContext.Provider,
2323
},
24+
globals: {
25+
locale: "en",
26+
locales: {
27+
en: "English",
28+
fr: "Français",
29+
},
30+
},
31+
i18n,
2432
};
2533

2634
addDecorator((storyFn) => (

packages/ui/components/unpublished-entity/unpublishedEntity.stories.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ The `UnpublishedEntity` component consists of the following parts:
2525
## UnpublishedEntity Story
2626

2727
<Canvas>
28-
<Story name="UnpublishedEntity">
29-
{() => (
30-
<VariantsTable titles={["Default"]} columnMinWidth={100}>
28+
<Story name="UnpublishedEntity" args={{ name: "TeamExample", teamSlug: "team-example" }}>
29+
{(args) => (
30+
<VariantsTable titles={["Default"]} columnMinWidth={150}>
3131
<VariantRow>
32-
<UnpublishedEntity />
32+
<UnpublishedEntity {...args} />
3333
</VariantRow>
3434
</VariantsTable>
3535
)}

0 commit comments

Comments
 (0)