Drawbacks of other i18n solutions
Using a pure javascript i18n framework
import React, { Component } from "react";
import { createRoot } from 'react-dom/client';
import i18n from "i18next";
// translation catalog
const resources = {
en: {
translation: {
"welcome": "Welcome to React and react-i18next"
}
}
};
// initialize i18next with catalog and language to use
i18n.init({
resources,
lng: "en"
});
class App extends Component {
render() {
return <h2>{i18n.t('welcome')}</h2>;
}
}
// append app to dom
const root = createRoot(document.getElementById('root'));
root.render(
<App />
);More react adapted "react-i18n"
The drawbacks
Changing the language
Scale and split your translations into multiple files
Can you translate combined jsx nodes in one sentence
Last updated