![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
i18next-lite
Advanced tools
Lightweight and super simple i18n/internationalization module for React.
i18next-lite is a lightweight and super simple i18n/internationalization module for React.
Why this? i18next-lite is specially designed only for React. Developed using modern React APIs. It is super simple, lightweight, fast and provides the necessary APIs to implement multiple language support.
npm i i18next-lite
A minimal example of implementing 3 languages with the ability to switch languages. Try/run this live on CodeSandbox.
import { createRoot } from 'react-dom/client'
import { TranslationProvider, useTranslate, useTranslatorConfigurer } from 'i18next-lite'
const translations = {
en: {
translation: {
hello: 'Hello {{userName}}',
good_morning: 'Good morning.',
how_are_you: 'How are you today?'
}
},
es: {
translation: {
hello: 'Hola {{userName}}',
good_morning: 'Buenos dias.',
how_are_you: '¿Cómo estás hoy?'
}
},
bn: {
translation: {
hello: 'হ্যালো {{userName}}',
good_morning: 'সুপ্রভাত.',
how_are_you: 'আপনি আজ কেমন আছেন?'
}
}
}
function App() {
return (
<TranslationProvider translations={translations} defaultLanguage='en'>
<ExampleComponent />
</TranslationProvider>
)
}
function ExampleComponent() {
const translate = useTranslate()
return (
<div>
<h2>{translate('hello', { userName: 'John Doe' })}</h2>
<h3>
{translate('good_morning')}
<br />
{translate('how_are_you')}
</h3>
<ExampleLanguageSwitcher />
</div>
)
}
function ExampleLanguageSwitcher() {
const configure = useTranslatorConfigurer();
return (
<div>
<div>Select language:</div>
<div>
<span onClick={() => configure({ language: 'en' })}>English</span> |
<span onClick={() => configure({ language: 'es' })}>Spanish</span> |
<span onClick={() => configure({ language: 'bn' })}>Bangla</span>
</div>
</div>
)
}
const rootElement = document.getElementById('root')
const root = createRoot(rootElement)
root.render(<App />)
The props of the TranslationProvider component:
Example:
function App() {
return (
<TranslationProvider
translations={translations}
defaultLanguage='en'
language='es'
>
...
</TranslationProvider>
)
}
In your React components, you can use the useTranslate hook to get the translate function.
const translate = useTranslate()
The parameters of the translate function:
For substitution, the keys are surrounded by curly brackets:
{
"greeting_message": "Hi {{userName}}. You have {{totalUnread}} messages."
}
Example:
translate("greeting_message", { userName: "Mr. White", totalUnread: 5 })
// → "Hi Mr. White. You have 5 messages."
In your React components, you can use the useTranslatorConfigurer hook to get the translator configure function. You can change the language or set the translations dynamically using this function.
const configure = useTranslatorConfigurer()
You can pass the following keys to the parameter of the configure function:
To change language:
const configure = useTranslatorConfigurer()
configure({ language: 'en' }) // Changes language to English.
Load/import translation data from one more JSON files. Check this CodeSandbox example for detailed instructions and file/folder structure.
const translations = {
...require('../src/locales/en.json'),
...require('../src/locales/es.json'),
...require('../src/locales/bn.json')
}
You are welcome to contribute! If you are adding a feature or fixing a bug, please contribute to the GitHub repository.
i18next-lite is licensed under the MIT license.
@SheikhAminul |
FAQs
Lightweight and super simple i18n/internationalization module for React.
The npm package i18next-lite receives a total of 73 weekly downloads. As such, i18next-lite popularity was classified as not popular.
We found that i18next-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.