amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

feat: Add `t.has` to check whether a given message exists #1399

Closed tholander closed 1 month ago

tholander commented 1 month ago
import {useTranslations} from 'next-intl';

function AboutPage() {
  const t = useTranslations('AboutPage');

  if (!t.has('title')) {
    notFound()
  }

  // ...
}

Closes #88

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 8:05am
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 8:05am
next-intl-example-app-router-without-i18n-routing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 8:05am
vercel[bot] commented 1 month ago

Someone is attempting to deploy a commit to the next-intl Team on Vercel.

A member of the Team first needs to authorize it.

blazingh commented 1 month ago

thanks a lot for this.