A minimal, but complete solution for internationalization in Next.js apps.
This library complements the internationalized routing capabilities of Next.js by managing translations and providing them to components.
children
as well as for attributes which expect strings.This library is based on the premise that messages can be grouped by namespaces (typically a component name).
// LatestFollower.js
function LatestFollower({user}) {
const t = useTranslations('LatestFollower');
return (
<>
<Text>{t('latestFollower', {username: user.name})}</Text>
<IconButton aria-label={t('followBack')} icon={<FollowIcon />} />
</>
);
}
// en.json
{
"LatestFollower": {
"latestFollower": "{username} started following you",
"followBack": "Follow back"
}
}