feature: language change API
- Dominant language
- JavaScript
- Stars
- 6.8k
- Forks
- 573
- PR merge metrics
- No merged PRs in 30d
Description
When implementing the new version of Bankai, I noticed that we always default to `en_US` and `ltr` for language. There have definitely been sites built on Choo using Farsi, Japanese and Arabic, all of which need different language attributes . It'd be cool if we had an API to set the language from within `choo`, and expose a property on the `state` which can be read to figure it out.
In an ideal scenario we could have a matrix of supported languages available, and then through an [`Accept-Language`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language) header, return the right version.
The browser currently has a [`'languagechange'`](https://developer.mozilla.org/en-US/docs/Web/Events/languagechange) event, and exposes a [`navigator.language`](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language) property. I couldn't find one for direction, but if someone knows of prior art it might be useful!
Keen to hear thoughts on the API; especially thoughts on how to create an output matrix for languages during SSR. Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.