Comments (6)
Hey @dustinsgoodman,
sure, I think you have these options:
- Return your messages from
getServerSideProps
of a page and pass them to the provider inApp
. - You can use
App.getInitialProps
to load common messages across all pages and pass them to the provider. I used to do that in the example in this repo, but switched togetStaticProps
since it's the way Next.js recommends. - A mixture of the two.
There's some documentation about this here: https://github.com/amannn/next-intl/blob/main/docs/usage.md#providing-messages
Does that help?
from next-intl.
Hey @amannn - that's definitely what I was looking for. Thank you! We'll try implementing this and see where it gets us. I'll keep you posted.
I think the problem with your option 1 is it won't populate all pages like getStaticProps
will but I think that's something we could solve with having both getStaticProps
and getServerSideProps
if Vercel would add that to Next.js.
from next-intl.
I need to think on the docs issue. I feel like there could have been something so we didn't chase our tails for a bit, but I'm not entirely sure if it's your library's responsibility to clarify that. I'll close and reopen a new issue if I think of something helpful. 😉
from next-intl.
@dustinsgoodman Were you able to get this working in your app?
from next-intl.
Discovered today that your option 1 works better than I expected. Seems like Next handles those server side props on page nav if you use next/link which is really nice and meets our needs. Thanks for your feedback. 😄
from next-intl.
Ok, that's great to hear! 🙂
Can this issue be closed then or is there something to improve about the documentation from your perspective?
from next-intl.
Related Issues (20)
- Matcher string in the docs is buggy HOT 1
- Pass `request` to `getRequestConfig()` HOT 3
- Switching language in sub-routes with dynamic routes throws an error HOT 6
- Importing createMiddleware() doesn't work as the tutorial suggests in type:module packages HOT 3
- Convenience injection of rewrites & exportPathMap HOT 3
- Domain based routing problem. HOT 2
- Verbose `localePrefix` does not redirect to the custom prefix HOT 3
- Allow for handling optional/invalid numbers on plural interpolation HOT 1
- Googlebot doesn't receieve translations HOT 2
- Middleware not running in NX monorepo project, causing "Unable to find `next-intl` locale" error HOT 8
- There is a problem with translation when the language family name has Hyphen HOT 1
- [Docs]: It is not clear to add pathnames to middleware file if you want to use localized pathnames HOT 1
- `redirect` from `createSharedPathnamesNavigation` doesn't handle relative paths HOT 1
- No default component was found HOT 1
- Allow usage of markup in addition to rich values in defaultTranslationValues HOT 3
- No any logic for `trailingSlash: true` HOT 5
- Inability to override locale on Date formatting results in incorrect localization HOT 2
- Using a multiples json in aplication HOT 1
- Router.replace from createLocalizedPathnamesNavigation causes infinite render HOT 1
- Open redirect vulnerability exposed when `localePrefix: 'as-needed'` HOT 1
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.