Closed sambrodie closed 1 month ago
Intl.getCanonicalLocales()
has some really weird idiosyncrasies. If you pass it a string that begins with 4 letters followed by a non-letter character, it will produce an error. But if you pass a string that begins with 5 or 6 characters, for example, it won’t. So:
post-name
> errorpost
> errorparent-page
> worksparent
> worksSo ultimately we can’t rely on Intl.getCanonicalLocales()
. Unfortunately, if we want to validate that string as a locale, and assume that the string can be any valid locale, it looks like we may have to use a library of all existing locales to compare it to.
Do we need validation for any possibly valid locale?
Could possibly use this: https://github.com/validatorjs/validator.js/blob/master/src/lib/isISO6391.js
But since that list isn't static, it would have to be maintained.
Describe the bug
When trying to view a page in the default language, the following error is thrown:
Error: Unsuported lang ([page slug]), make sure you add all desired locales to "config.i18n.locales"
For example if the page is /my-page, the error would be:
Error: Unsuported lang (my-page), make sure you add all desired locales to "config.i18n.locales"
Steps to Reproduce
Screenshots, screen recording, code snippet
Languages: https://share.zight.com/p9uoRBgN Error: https://share.zight.com/12ujpbBe
Environment information
No response
WordPress information
No response
Code of Conduct