π Internationalization (i18n) for Next.js
See the codeInternationalization for Next.js.
Internationalization (i18n) is an essential part of the user experience, therefore next-intl gives you all the parts you need to get language nuances right.
// UserProfile.tsx
import {useTranslations} from 'next-intl';
export default function UserProfile({user}) {
const t = useTranslations('UserProfile');
return (
<section>
<h1>{t('title', {firstName: user.firstName})}</h1>
<p>{t('membership', {memberSince: user.memberSince})}</p>
<p>{t('followers', {count: user.numFollowers})}</p>
</section>
);
}
// en.json
{
"UserProfile": {
"title": "{firstName}'s profile",
"membership": "Member since {memberSince, date, short}",
"followers": "{count, plural, β΅
=0 {No followers yet} β΅
=1 {One follower} β΅
other {# followers} β΅
}"
}
}
As an app grows, messages may drift and become inconsistent.
A companion tool, eloqnt/cli, catches this by analyzing your source code and messages statically:
$ eloqnt lint
messages/de.json
β
β "UserProfile.title": "Dein Profil"
β ββ¬ββββββββββ
β β°β Inconsistent ICU arguments: missing {firstName} (inconsistent-args)
β
β "UserProfile.membership": "Member since {memberSince, date, short}"
β ββ¬ββββββββββββββββββββββ
β β°β Missing translation for de (missing-translation)
β 1 error
! 1 warning
β Rule details: https://cli.eloqnt.dev/docs/lint-rules/<rule>
β Run `eloqnt translate` to fill in 1 missing translation
It can optionally also fill in missing translations with eloqnt translate, using your source code as context.
(top 30 of 88)
TypeScript
93.7%
Rust
3.4%
JavaScript
2.9%
π Internationalization (i18n) for Next.js
See the codeInternationalization for Next.js.
Internationalization (i18n) is an essential part of the user experience, therefore next-intl gives you all the parts you need to get language nuances right.
// UserProfile.tsx
import {useTranslations} from 'next-intl';
export default function UserProfile({user}) {
const t = useTranslations('UserProfile');
return (
<section>
<h1>{t('title', {firstName: user.firstName})}</h1>
<p>{t('membership', {memberSince: user.memberSince})}</p>
<p>{t('followers', {count: user.numFollowers})}</p>
</section>
);
}
// en.json
{
"UserProfile": {
"title": "{firstName}'s profile",
"membership": "Member since {memberSince, date, short}",
"followers": "{count, plural, β΅
=0 {No followers yet} β΅
=1 {One follower} β΅
other {# followers} β΅
}"
}
}
As an app grows, messages may drift and become inconsistent.
A companion tool, eloqnt/cli, catches this by analyzing your source code and messages statically:
$ eloqnt lint
messages/de.json
β
β "UserProfile.title": "Dein Profil"
β ββ¬ββββββββββ
β β°β Inconsistent ICU arguments: missing {firstName} (inconsistent-args)
β
β "UserProfile.membership": "Member since {memberSince, date, short}"
β ββ¬ββββββββββββββββββββββ
β β°β Missing translation for de (missing-translation)
β 1 error
! 1 warning
β Rule details: https://cli.eloqnt.dev/docs/lint-rules/<rule>
β Run `eloqnt translate` to fill in 1 missing translation
It can optionally also fill in missing translations with eloqnt translate, using your source code as context.
(top 30 of 88)
TypeScript
93.7%
Rust
3.4%
JavaScript
2.9%