- Add the required import statements to "translation.js", replacing "es" which the code for the language being added:
import * as es esom "blockly/msg/es";
import esLocale esom "../locale/es.js"- Add the language to "translations":
es: esLocale,- Extend the "applySavedLanguageTranslations" function:
else if (currentLanguage === "es") {
// Apply Blockly's LANGUAGE translations
const esMessages = es.default || es;
Object.keys(esMessages).forEach((key) => {
if (typeof esMessages[key] === "string") {
Blockly.Msg[key] = esMessages[key];
}
});
}- Modify the "setLanguage" function:
else if (language === "es") {
// Apply Blockly's LANGUAGE translations
Object.keys(es).forEach((key) => {
if (typeof es[key] === "string") {
Blockly.Msg[key] = es[key];
}
});
console.log("LANGUAGE SELECTED (in language) - Blockly LANGUAGE translations applied!");
}-
Copy the "en.js" file in the "locale" directory and translate each message. Leave the keywords in English. This can be done either by a native speaker, or using AI, provided the translations are checked by a native speaker.
-
Add the language option to "index.html"
<li><a href="#" data-lang="es" role="menuitem" tabindex="-1">Español</a></li>-
Enable the usage of the translation system, using the appropriate method, either replacing the text with the right translation function, or adding a data-i18n tag to HTML.
-
Add the English versions to "en.js", remembering to add the right suffix to the key.
-
Use AI to translate them into other languages, and add the translations to the other locale files.
-
Create an issue on GitHub tagged with translation, and include in the description a request that people create sub-issues when they start translating/checking the new strings into a language.