Comments (7)
Hey @amannn would you mind take a look? Thanks in advance
from next-intl.
Hey! I've been on vacation for a few weeks, sorry for the late reply.
Is there a [locale]
segment somewhere in your pathname? If yes, this might be a duplicate of #1107. If not, you should be able to derive a locale from the domain by reading this in i18n.ts
(see: Setup without i18n routing: i18n.ts
).
Does that cover your use case?
from next-intl.
Hey @amannn thanks for the reply. Unfortunately, I can't read domain
from i18n.ts
, because it'll convert /app/blog/[domain]
into SSR (reading headers in this case), but we need static generation here. Is it possible to inject messages into the message source of useTranslations
when SSG? Thus we don't need i18n.ts
at all.
from next-intl.
How do the public pathnames look like to the user? Is [domain]
visible? Is there a [locale]
segment, or does a domain only support a single locale? Can you provide an overview of how pathnames look like to the user and what needs to be matched internally?
There was a very similar case discussed here: #1107 (comment) (see the note with the adapted x-middleware-rewrite
header). This turned out to work for a user. Maybe this is helpful to you!
Is it possible to inject messages into the message source of
useTranslations
when SSG?
I don't think that's possible, no. i18n.ts
is always consulted to load i18n config for Server Components.
from next-intl.
@amannn Sorry for the delay. Yes, the domain only support one single locale, we don't have [locale]
or anything similar in the path, we save the locale to a db and read it when SSG. I took a glance of the issues you mentioned, I don't think read db in middleware is ideal, the latency would be unacceptable...
from next-intl.
I see. If SSG is mandatory anyway, you could consider using unstable_setRequestLocale
to pass a locale depending on a domain to next-intl
. You need to ensure that this is consistently called in each layout and page before any calls to next-intl
happen.
Ideally you'd be able to return a locale
based on a [domain]
segment in i18n.ts
, but Next.js currently doesn't support that (see #663).
from next-intl.
One more thought: You do have an infinite number of domains, is that correct? Otherwise the domains
configuration setting from next-intl
should already support your use case well.
from next-intl.
Related Issues (20)
- Error Occurs When Calling cookies() in getRequestConfig() HOT 4
- Wrong document HOT 1
- Pathnames with 2 dynamics values of the same name require 2 different params HOT 1
- Example-app-router error when using output: 'export' (SSG) HOT 1
- Unable to find `next-intl` locale because the middleware didn't run on this request. HOT 1
- next-intl does not output index.html file HOT 1
- router issue when switching locale: path.startsWith is not a function HOT 8
- Incompatibility of Server-Side Functions with Client Component Layout in Next.js 14 /app HOT 1
- How to send the language (locale) code to Fetch operations processed by the Client Side? HOT 1
- Unable to Use loading.tsx with next-intl in App Router with i18n Routing HOT 4
- NextJS 15 support HOT 2
- Cannot retrieve Link's props from createLocalizedPathnamesNavigation HOT 1
- Middleware should gracefully handle unsupported but valid locale identifiers HOT 1
- Next.js - Navigation between pages in the pages router loses translations. HOT 3
- [Docs]: Typescript Validation HOT 1
- NextJS 15's `next/font` breaks alternate header injection. HOT 3
- Add Support for Setting HttpOnly and Secure Flags on NEXT_LOCALE Cookie HOT 4
- Localized search/query params HOT 1
- Using Link component with legacyBehavior+passHref producing warnings HOT 3
- getPathname with params HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-intl.