Multilingual Greetings React Js Github -
, hi: translation: greeting: "नमस्ते, name! एप्लिकेशन में आपका स्वागत है।", select_lang: "भाषा चुनें"
return ( <div style=styles.container> <h2>t('select_lang')</h2> <select value=i18n.language onChange=(e) => changeLanguage(e.target.value) style=styles.select > <option value="en">🇺🇸 English</option> <option value="es">🇪🇸 Español</option> <option value="fr">🇫🇷 Français</option> <option value="ja">🇯🇵 日本語</option> <option value="hi">🇮🇳 हिन्दी</option> </select>
const styles = container: textAlign: 'center', padding: '2rem', fontFamily: 'sans-serif' , select: padding: '0.5rem 1rem', fontSize: '1rem', marginBottom: '2rem', cursor: 'pointer' , card: backgroundColor: '#f5f5f5', borderRadius: '12px', padding: '2rem', maxWidth: '400px', margin: '0 auto', boxShadow: '0 4px 12px rgba(0,0,0,0.1)' , input: padding: '0.5rem', fontSize: '1rem', marginTop: '1rem', width: '80%', borderRadius: '8px', border: '1px solid #ccc' multilingual greetings react js github
<div style=styles.card> <h3>t('greeting', name )</h3> <input type="text" placeholder="Enter your name" value=name onChange=(e) => setName(e.target.value) style=styles.input /> </div> </div> ); ;
export default i18n;
In today’s globalized world, a simple "Hello" can open doors. But what if your React app needs to say "Bonjour," "Hola," or "こんにちは"? That’s where (i18n) comes in.
, fr: translation: greeting: "Bonjour, name ! Bienvenue dans l'application.", select_lang: "Choisir la langue" , hi: translation: greeting: "नमस्ते, name
i18n .use(initReactI18next) .init( resources, lng: "en", // default language fallbackLng: "en", interpolation: escapeValue: false // React already safes from XSS
);