diff --git a/README.md b/README.md index 3f8bf92..6d6f85d 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ bun run dev pnpm dev ``` -Open [http://localhost:3000/en](http://localhost:3000/en) with your browser to see the result. +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. diff --git a/app/[lang]/favicon.ico b/app/favicon.ico similarity index 100% rename from app/[lang]/favicon.ico rename to app/favicon.ico diff --git a/app/[lang]/globals.css b/app/globals.css similarity index 100% rename from app/[lang]/globals.css rename to app/globals.css diff --git a/app/[lang]/growthbook.ts b/app/growthbook.ts similarity index 100% rename from app/[lang]/growthbook.ts rename to app/growthbook.ts diff --git a/app/[lang]/layout.tsx b/app/layout.tsx similarity index 100% rename from app/[lang]/layout.tsx rename to app/layout.tsx diff --git a/app/[lang]/page.tsx b/app/page.tsx similarity index 100% rename from app/[lang]/page.tsx rename to app/page.tsx diff --git a/app/[lang]/providers.tsx b/app/providers.tsx similarity index 100% rename from app/[lang]/providers.tsx rename to app/providers.tsx diff --git a/components/hello-world/hello-world.stories.ts b/components/hello-world/hello-world.stories.ts index 0b3934a..92b9545 100644 --- a/components/hello-world/hello-world.stories.ts +++ b/components/hello-world/hello-world.stories.ts @@ -15,10 +15,16 @@ const meta = { export default meta; type Story = StoryObj; -export const LoggedIn: Story = { +export const LangdEn: Story = { args: { name: 'Jane Doe', + lang: 'en', }, }; -export const LoggedOut: Story = {}; +export const LangEs: Story = { + args: { + name: 'Jane Doe', + lang: 'es', + }, +}; diff --git a/dictionaries/index.ts b/dictionaries/index.ts index 55a43c2..48a3b96 100644 --- a/dictionaries/index.ts +++ b/dictionaries/index.ts @@ -6,4 +6,5 @@ const dictionaries = { es: () => import('./es.json').then((module) => module.default), }; -export const getDictionary = async (locale: Locales) => dictionaries[locale](); +export const getDictionary = async (locale: Locales) => + dictionaries[locale]?.() ?? dictionaries.en(); diff --git a/i18n-config.ts b/i18n-config.ts new file mode 100644 index 0000000..46b2e75 --- /dev/null +++ b/i18n-config.ts @@ -0,0 +1,6 @@ +export const i18n = { + defaultLocale: 'en', + locales: ['en', 'es'], +} as const; + +export type Locale = (typeof i18n)['locales'][number];