Hi,
I'm trying to create a multilingual blockly, like in code demo. But this demo is not up to date and use old code, not setLocale function.
But I don't success using a dropdown menu in setLocale function. I don't want to do something like
"if (languageMenu.options[languageMenu.selectedIndex].value == 'fr') Blockly.setLocale(Fr)
else
if (languageMenu.options[languageMenu.selectedIndex].value == 'en') Blockly.setLocale(En)
else if..."
Thanks.
What I tried (but there's a type problem with 'string' and '{ [key: string]: string; }' types):
const µcB_changeLanguage = (): void => {
const languageMenu: HTMLSelectElement = document.getElementById('languageMenu') as HTMLSelectElement;
const newLang: any = encodeURIComponent(languageMenu.options[languageMenu.selectedIndex].value);
const data = Blockly.serialization.workspaces.save(workspace);
µcB.workspace.clear();
Blockly.setLocale(newLang);
Blockly.serialization.workspaces.load(JSON.parse(data), workspace);
};