Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs]: Is next-intl supported in axios? #1648

Closed
lynn1286 opened this issue Jan 6, 2025 · 1 comment
Closed

[Docs]: Is next-intl supported in axios? #1648

lynn1286 opened this issue Jan 6, 2025 · 1 comment
Labels
documentation Improvements or additions to documentation unconfirmed Needs triage.

Comments

@lynn1286
Copy link

lynn1286 commented Jan 6, 2025

Link to page

https://next-intl.dev/docs/getting-started/pages-router

Describe the problem

Based on 3.0 documentation ,I implemented I18n using next14's pages router.

But I have a couple of quibbles I'd like help with:

  1. Is there any way to do this other than using getInitialProps in _app.tsx to return [locale].json? Because according to nextjs, using getInitialProps in _app.tsx will cause the static optimizations to lose their effectiveness
  2. How should I use next-intl outside of react components in pages router, for example if I need to use next-intl in my axios interceptor, how do I do it?
@lynn1286 lynn1286 added documentation Improvements or additions to documentation unconfirmed Needs triage. labels Jan 6, 2025
@amannn
Copy link
Owner

amannn commented Jan 9, 2025

(1) Yep, you can also use getStaticProps.

(2) Please see https://next-intl.dev/blog/translations-outside-of-react-components. For edge cases like API Routes in the Pages Router, you can optionally resort to createTranslator.

I'll move this to a discussion since it's a usage question.

Repository owner locked and limited conversation to collaborators Jan 9, 2025
@amannn amannn converted this issue into discussion #1652 Jan 9, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
documentation Improvements or additions to documentation unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants