A super-simple i18n solution for React app.
i18n.json
{
"nav": {
"homePage": {
"zh-CN": "ๅๅฎข",
"en-US": "Home"
},
"secondPage": {
"zh-CN": "ๅฏ้ๅฐ",
"en-US": "Special"
},
"search": {}
}
}
import Text from "../../utils/i18n";
import { nav } from "../../data/i18n.json";
const Menu = ({ lang }): React.ReactElement => {
return (
<ul className="app-header-list">
<Text dictionary={nav} language={lang}>
{[
{
text: <Text homePage />,
to: "/",
},
{
text: <Text secondPage />,
to: "/special",
},
].map((item, i) => (
<ActiveLink
activeClassName="app-header-list-item-active"
href={item.to}
>
<a className="app-header-list-item">{item.text}</a>
</ActiveLink>
))}
</Text>
</ul>
);
};
MIT