React
react-i18nextnpm install i18next react-i18next i18next-browser-languagedetector i18next-locize-backendimport i18n from 'i18next'
import { initReactI18next, useTranslation } from 'react-i18next'
import LanguageDetector from 'i18next-browser-languagedetector'
import Backend from 'i18next-locize-backend'
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'en',
saveMissing: true, // sends new keys to Locize
backend: {
projectId: '[PROJECT_ID]',
apiKey: '[API_KEY]', // dev only — drop in production
}
})
// In a component:
function Welcome () {
const { t } = useTranslation()
return <h1>{t('welcome.title', 'Welcome')}</h1>
}