Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .storybook/preview.ts

This file was deleted.

25 changes: 25 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Preview } from '@storybook/react';
import React from 'react';
import { I18nextProvider } from 'react-i18next';
import "../app/i18n/config";
import i18n from '../app/i18n/config';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
decorators: [
(Story) => (
<I18nextProvider i18n={i18n}>
<Story />
</I18nextProvider>
),
],
};

export default preview;
8 changes: 4 additions & 4 deletions app/components/Button/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ type Story = StoryObj<typeof meta>;
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
label: 'common.button',
},
};

export const Secondary: Story = {
args: {
label: 'Button',
label: 'common.button',
},
};

export const Large: Story = {
args: {
size: 'large',
label: 'Button',
label: 'common.button',
},
};

export const Small: Story = {
args: {
size: 'small',
label: 'Button',
label: 'common.button',
},
};
5 changes: 3 additions & 2 deletions app/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

import { useTranslation } from 'react-i18next';
import './button.css';

export interface ButtonProps {
Expand All @@ -24,14 +24,15 @@ export const Button = ({
...props
}: ButtonProps) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
const { t } = useTranslation();
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
style={{ backgroundColor }}
{...props}
>
{label}
{t(label)}
</button>
);
};
27 changes: 27 additions & 0 deletions app/i18n/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";

import translation_en from "./en.json";
import translation_ja from "./ja.json";

const resources = {
ja: {
translation: translation_ja
},
en: {
translation: translation_en
}
};

i18n
.use(initReactI18next)
.init({
resources,
lng: "ja",
fallbackLng: "ja",
interpolation: {
escapeValue: false
}
});

export default i18n;
10 changes: 10 additions & 0 deletions app/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"common": {
"button": "Button"
},
"card": {
"memberCard": {
"stack": "Stacks"
}
}
}
10 changes: 10 additions & 0 deletions app/i18n/ja.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"common": {
"button": "ボタン"
},
"card": {
"memberCard": {
"stack": "得意技術"
}
}
}
1 change: 1 addition & 0 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

import type { Route } from "./+types/root";
import "./app.css";
import "./i18n/config";

export const links: Route.LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
Expand Down
75 changes: 73 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
"dependencies": {
"@react-router/node": "^7.3.0",
"@react-router/serve": "^7.3.0",
"i18next": "^24.2.3",
"isbot": "^5.1.17",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-i18next": "^15.4.1",
"react-router": "^7.3.0"
},
"devDependencies": {
Expand Down