Closed Choozii closed 2 weeks ago
import ReactDOM from 'react-dom/client'; import App from './App.tsx'; import { TranslationProvider } from './context/TranslationContext'; const translations = { en: { greeting: 'Hello ${name}, You have ${count} new messages.', farewell: 'Goodbye ${name}', }, ko: { greeting: '์๋ ํ์ธ์ ${name}, ์ ๋ฉ์์ง๊ฐ ${count}๊ฐ ์์ต๋๋ค.', farewell: '์๋ ํ ๊ฐ์ธ์ ${name}', }, }; ReactDOM.createRoot(document.getElementById('root')!).render( <TranslationProvider translations={translations} defaultLanguage="en"> <App />{' '} </TranslationProvider> );
import { useTranslation } from './hooks/useTranslation'; const App = () => { const { t, language, changeLanguage } = useTranslation(); const handleLanguageChange = (lang: string) => { changeLanguage(lang); }; return ( <div> <h1>{t('greeting', { name: 'Choo', count: 5 })}</h1> <p>{t('farewell', { name: 'Choo' })}</p> <div> <button onClick={() => handleLanguageChange('en')}>English</button> <button onClick={() => handleLanguageChange('ko')}>ํ๊ตญ์ด</button> </div> <p>Current Language: {language}</p> </div> ); }; export default App;
๐พ Pull Request
1๏ธโฃ Spec
3๏ธโฃ ์์ ์ฝ๋
4๏ธโฃ ๊ด๋ จ ๋ฌธ์ (์ ํ ์ฌํญ)