chore(i18n): reworked fallback, docs, types and validation#8995
chore(i18n): reworked fallback, docs, types and validation#8995ematipico merged 3 commits intofeat/i18n-routingfrom
Conversation
|
fc93dbb to
71f94fb
Compare
sarah11918
left a comment
There was a problem hiding this comment.
These are fabulous updates! Just a few minor suggestions. Thank you for hanging in there with me as I try to get all of these options straight in my head. 😅
| * The content fallback strategy when navigating to pages in non-default languages that do not exist. (e.g. a translated page has not been created). | ||
| * | ||
| * This a plain object, where a key is a locale that hasn't traslated pages, and the corresponding value is the locale where you want to redirect the missing page to. |
There was a problem hiding this comment.
| * The content fallback strategy when navigating to pages in non-default languages that do not exist. (e.g. a translated page has not been created). | |
| * | |
| * This a plain object, where a key is a locale that hasn't traslated pages, and the corresponding value is the locale where you want to redirect the missing page to. | |
| * The content fallback strategy when navigating to pages in non-default languages that do not exist (e.g. a translated page has not been created). | |
| * | |
| * Use this object to declare a fallback `locale` for each language you support individually. If no fallback is specified, then unavailable pages will return a 404. |
This looks great!
I made up that sentence at the end, because I think it helps to say what happens if you don't configure anything.
I think a common thing to want to do here will be to make the one default fallback, and not have to list every language out individually. So, if the above is true, that's also very useful for doing this! If the above is NOT true, then I think we need to tell them how to set one default language for all other languages, as I expect this to be a common use case.
EDIT: changed "then all languages listed in locales will redirect the page to your defaultLocale"
There was a problem hiding this comment.
The reason why I haven't put any default fallback is because:
- we do want to avoid redirects as much as possible as default behaviour
- it's possible that users don't require this feature (localised market, legal documents, etc.), so it would get more complicated to opt out of the default behaviour
About this suggestion:
If no fallback is specified, then all languages listed in
localeswill redirect the page to yourdefaultLocale.
As for now, we won't redirect to the defaultLocale, which means that if the user doesn't set a fallback for a locale, the missing pages will return 404.
We can explore a redirect behaviour later on
There was a problem hiding this comment.
Updated the comment (and the other one) with acceptable placeholder language that I'll check on! This is good enough to merge!
sarah11918
left a comment
There was a problem hiding this comment.
Approving and my task is to make sure we're saying "returns a 404" properly and consistently before publishing! Great changes here!
71f94fb to
177ee1f
Compare
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
There was some issue with the types of
i18n.fallback, and I added another level of validation to zod.Testing
Added a test case to cover the new logic
Docs
/cc @withastro/maintainers-docs for feedback!
@sarah11918 we can use this PR to land the correct documentation for fallback