amannn / next-intl

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

cannot use request.tsx #1317

Closed swajp closed 2 months ago

swajp commented 2 months ago

Description

in the docs there is

i18n/request.ts

but for the code example ti is i18n/request.tsx

image

and if want to use the tsx because i need to default the translations valuest it tells me that request.ts doesnt exist

image

my code

import { notFound } from "next/navigation"
import { getRequestConfig } from "next-intl/server"
import { routing } from "./routing"

export default getRequestConfig(async ({ locale }) => {
    // Validate that the incoming `locale` parameter is valid
    if (!routing.locales.includes(locale as any)) notFound()

    return {
        defaultTranslationValues: {
            strong: chunks => <strong>{chunks}</strong>
        },
        messages: (await import(`../../messages/${locale}.json`)).default
    }
})

Verifications

Mandatory reproduction URL

-

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Click on …
  3. See error: …

Expected behaviour

It shouldnt throw me an error because it is showed in docs as an example

amannn commented 2 months ago

It should definitely work, can you share a reproduction that shows a broken setup? Something you could try is restarting your dev server in case you've renamed the file.

github-actions[bot] commented 2 months ago

Thank you for your report!

Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically.

Templates:

Creating a good bug report takes time.

To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you.

Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:

  1. Open reproduction
  2. Click on …
  3. See error: …

Thank you for your understanding!

FAQ **"I've included a reproduction, what is missing?"** This comment might have been added because your reproduction doesn't point to a destination where the issue can be reproduced. Please make sure that the latest changes were saved in the reproduction and that the link is correct.
swajp commented 2 months ago

my bad... i'm sorry.. deleting .next and running it again helped... sory for you time

amannn commented 2 months ago

Ok sure, good to hear if it works now for you.