Description
In local dev it seems to work. But what happens in the deployed version is that MakeCode writes the updated language to the cookie, just reloads the page without changing the lang= parameter on the URL. But at init time MakeCode prioritises lang=whatever over the cookie and we use that to propagate CreateAI's language preference to MakeCode. So it copies that unchanged lang=en value to the cookie. If you watch the cookie you see it change e.g. en -> fr -> en again after the reload.
A non-exhaustive set of options we've considered:
- No language menu in MakeCode (e.g. via an option)
- A reimplemented header that can have CreateAI's language menu (like micro:bit classroom)
- Some way to make MakeCode take the code path that updates the URL if the language was specified by URL in the first place. Requires MakeCode change. At the moment it only does this if it thinks cookies aren’t working (can’t read back language cookie).
- A way to make MakeCode prioritise cookie language over URL
- Add/change MakeCode iframe messages to set initial language, change it and broadcast changes in MakeCode
In the short term we're likely to ship languages without a working language menu in MakeCode as you'd likely need to change language earlier than MakeCode anyway.
(5) seems like the nicest approach but will need a non-trivial MakeCode change. But there's also the complication of MakeCode supporting more languages than CreateAI, and (2) or (5) + API to limit language choice in MakeCode are the only ways to address that (or 1, I guess).
One for discussion.