Refresh necessary to get the translations of all the blocks

118 views
Skip to first unread message

nico-oops

unread,
Aug 31, 2022, 5:18:15 AM8/31/22
to Blockly
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.

I have followed the guide of the official blockly website https://developers.google.com/blockly/guides/configure/web/translations to implement the translation of all the blocks, but either there is a bug or I am doing something wrong.

Here the source code https://github.com/XDinEuro/blockly-test/blob/fix_translation_issue/src/components/Toolbox.vue with the current implementation.

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"),


nico-oops

unread,
Aug 31, 2022, 5:54:23 AM8/31/22
to Blockly
blockly.png
The above one is the behaviour switching to English from German without refreshing.
The one below is the behaviour after refreshing.
blockly_refreshed.png

Beka Westberg

unread,
Sep 2, 2022, 12:33:01 PM9/2/22
to Blockly
Yeah, dropdowns have a known bug where they don't update in response to translations :/ There are workarounds documented here. Please feel free to upvote that main issue to let us know fixing it is important to you!

I hope that helps! If you have any further questions please reply =)
--Beka

Reply all
Reply to author
Forward
0 new messages