next-intl.
The default language is set in the app config. To disable url-based language switching, set NEXT_PUBLIC_ENABLE_LANG_ROUTING to 0. You should only disable this if you have a single language.
tsx web/appConfig.tsx
Adding and using translations
Translations are stored in theweb/i18n/messages directory. Each language has its own folder with translation files.
I would recommend creating a separate file for each component (or group of components) or page to keep the translations organized.
web/i18n/config.ts file to register the translations.
To use translations in your components, import the useTranslations hook from next-intl and use it to access the translations. For server-side rendering, use the getTranslations function.
tsx web/app/[locale]/(protected)/layout.tsx
error.title in the pricing.json file in the current language folder.
Adding or modifying languages
- Creating a new folder in the
web/i18n/messagesdirectory. The folder name should be the language code (e.g.defor German). - Create your translation files according to the existing structure.
- Add the new language to the
localesarray in theweb/i18n/locales.tsfile.
tsx web/i18n/locales.ts
- Add the new language to
web/middleware.tsandnext-sitemap.config.jsfiles. (Unfortunately, the compiler does not allow importing the locales file so we need to define it manually).
web/next-sitemap.config.js
web/middleware.ts
appConfig.i18n.enableLangRouting is set to true. Use it via <LanguagePicker /> in your components.

