Skip to content

Use next-intl as package in turborepo monorepo #1688

Answered by sakib412
naquiroz asked this question in Q&A
Discussion options

You must be logged in to vote

I am doing this way.
packages/i18n/src/request.ts :

import {hasLocale} from 'next-intl';
import {getRequestConfig} from 'next-intl/server';

import {routing} from './routing';

export default getRequestConfig(async function createRequestConfig({
  requestLocale,
}) {
  // This typically corresponds to the `[locale]` segment
  const requested = await requestLocale;
  const locale = hasLocale(routing.locales, requested)
    ? requested
    : routing.defaultLocale;

  let messages;
  try {
    messages = (
      await (locale === routing.defaultLocale
        ? import(`../messages/en.json`)
        : import(`../messages/${locale}.json`))
    ).default;
  } catch (error) {
    console.error(`…

Replies: 4 comments 23 replies

Comment options

You must be logged in to vote
11 replies
@pericleschrstn
Comment options

@johnschult
Comment options

@pericleschrstn
Comment options

@samblongchamps
Comment options

@loadingalias
Comment options

Comment options

You must be logged in to vote
2 replies
@amannn
Comment options

@fernandojbf
Comment options

Comment options

You must be logged in to vote
2 replies
@johnschult
Comment options

@RicardoAvans
Comment options

Comment options

You must be logged in to vote
8 replies
@sakib412
Comment options

@RicardoAvans
Comment options

@sakib412
Comment options

@RicardoAvans
Comment options

@madikmaycryeyewa
Comment options

Answer selected by naquiroz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request unconfirmed Needs triage.
10 participants
Converted from issue

This discussion was converted from issue #1687 on January 28, 2025 09:11.