Hello everyone!
I am having some issues on implementing the blocks translation.
I have implemented some blocks and the possibility to switch between three languages (English, Chinese and German). There is a menu where you can select the language you want.
The current behaviour is the following:
It is not enough to select the language from the menu to get all the blocks translated, but I also need to refresh the page, otherwise only some blocks are translated but others are not.
Why is that? Do you guys have some hints for me? I would really appreciate it.
import Blockly from "blockly";
import { onMounted } from "vue";
import * as De from 'blockly/msg/de';
import * as En from 'blockly/msg/en';
import * as Cn from 'blockly/msg/zh-hans';
import { useI18n } from "vue-i18n";
import {ref} from "vue";
export default {
name: "Toolbox",
setup() {
onMounted(() => {
const i18n = ref(useI18n({ useScope: "global" })).value;
if(i18n.locale === "de-DE") Blockly.setLocale(De);
else if(i18n.locale=== "en-US") { Blockly.setLocale(En)
}
else if(i18n.locale === "cn-CN") Blockly.setLocale(Cn)
Blockly.inject(document.querySelector("#category-block"), {
toolbox: document.querySelector("#toolbox"),