Comments (5)
@rengert thank you for the comment. Will look into it, and update if locale is not set to throw a more appropriate error.
from nextjs-corporate-starter.
Same for me. The middleware picks the preferred language from the 'Accept-Language' header. Which is German for me. You can easily modify the code to always use 'en' or remove 'de' from the i18n settings (there needs to be a match between preferred language and available languages). Anyway, there is a check, if page data is available in the requested language and if not, a language selector component should be displayed, avoiding any errors. But this is not working as expected, still don't found out why. But keep searching.
from nextjs-corporate-starter.
@mbieberstein I haven't had a chance to take a look in more detail into this issue yet, if you end up finding the issue first let us know or feel free to make a PR request.🙂
from nextjs-corporate-starter.
I have same issue when trying to open a link with newly added locale
Uncaught Error: invariant expected app router to be mounted at useRouter
from nextjs-corporate-starter.
@eugene-beliaev This is a next.js error. It complains about missing HTML and BODY tags in the response.
Look at my previous comment for an explanation.
The fallback mechanism for missing page data in a certain locale will never be reached, when the global configuration (navigation, etc.) is also not available in that locale. In that case the global layout.tsx returns null, which results in an empty layout. That's what next complains about.
in line 64 in frontend\src\app[lang]\layout.tsx you find this comment: // TODO: CREATE A CUSTOM ERROR PAGE
So, this seems to be work in progress. But I suggest to redirect to the default locale instead of treating this as an error.
Missing global configuration in a certain locale indicates, that there wont be any content available either.
@PaulBratslavsky In my opinion: The available locales should not be hard coded in the i18n configuration, but retrieved from the strapi localization api (needs to be public then).
At first, the preferred locale of the user is determined by the Accept-Language header: ok. If this preference does not match the available locales, a redirect to the (strapi) default locale takes place. But this fallback locale needs to be persisted in the user session (cookie), otherwise this roundtrip will happen on each subsequent request.
There should be a possibility for the user to select the locale (dropdown in navigation, etc.) to switch preferences. This selection should then update the cookie value, which functions as the 'master' locale.
Anyway, there needs to be content available in every supported locale, at least on the global level. If certain pages are not available in that locale, the fallback component should appear. But the link to the default locale needs to be dynamic, redirecting to the requested page, not home.
I am currently working on a POC for this mechanism and, as you suggested, will make a PR as soon as it works.
from nextjs-corporate-starter.
Related Issues (20)
- Next 14 & Strapi Demo Project Is Here HOT 3
- [Bug] Localization issue HOT 4
- Typescript - Using the 'model.ts' file [ I added a post at the bottom on guide to implement Strapi types in the frontend. HOT 1
- Bug - responsive menu doesn't work correctly and overlay text and logo HOT 4
- TODO: Suggestion: Remove NEXT_PUBLIC Prefix for API Keys in .env File HOT 2
- Could you please add a LICENSE information. HOT 1
- TODO: Implement The Large Video Component from the Dynamic Component In The Frontend [ Issue ] HOT 3
- Multilungual Styles HOT 2
- site loads fine, when I refresh blog page it renders json chunks , not html HOT 2
- No documentation on deploying to Vercel HOT 3
- Images for navbarLogo, footerLogo & testimonials are not set by default, causing the frontend not to load HOT 2
- Reference Error: window is not defined? HOT 6
- Seed into mysql doesn't work HOT 3
- Adding a picture in Sections HOT 4
- Warnings during yarn setup HOT 1
- error after fixing page,tsx (invariant expected app router to be mounted ) HOT 2
- Replace Gif with .mp4
- Custom color breaks the style
- Relations of type error 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 nextjs-corporate-starter.