Skip to content

Commit 0ec1b98

Browse files
Update translations, add French language for preview (#610)
1 parent 30a74a5 commit 0ec1b98

23 files changed

+4852
-113
lines changed

bin/update-translations.cjs

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
* pxt-microbit-ml machine-learning-strings.json. See CodeViewDefaultBlock.tsx
55
* to see where they are used.
66
*
7-
* To update all translations, pass 2 arguments:
8-
* 1. Path to CreateAI tool translation strings directory.
9-
* 2. Path to machine-learning-strings.json translation strings directory.
10-
*
11-
* To only update CreateAI tool translations, pass path to CreateAI tool
12-
* translation strings directory as an argument.
7+
* Pass path to extracted Crowdin ZIP
138
*
149
* Manually run `npm run i18n:compile` after.
1510
*
@@ -20,11 +15,24 @@ const fs = require("fs");
2015
const okExitStatus = 0;
2116
const errExitStatus = 2;
2217

23-
const languages = ["ca", "en", "es-ES", "ja", "ko", "nl", "pl", "pt-br", "zh-tw", "lol"];
18+
const languages = [
19+
"ca",
20+
"en",
21+
"es-ES",
22+
"fr",
23+
"ja",
24+
"ko",
25+
"nl",
26+
"pl",
27+
"pt-BR",
28+
"zh-TW",
29+
"lol",
30+
];
2431
const enMessagesToAdd = {
2532
"ml.onStart|block": {
2633
defaultMessage: "on ML $event start",
27-
description: "This string should be a Crowdin duplicate of the MakeCode extension block with the same text and use the same translation.",
34+
description:
35+
"This string should be a Crowdin duplicate of the MakeCode extension block with the same text and use the same translation.",
2836
},
2937
};
3038

@@ -41,21 +49,23 @@ const getMessagesToAdd = (mlStrings, langMessages) => {
4149
if (!langMessages[k]) {
4250
return { ...acc, [k]: { ...enMessagesToAdd[k] } };
4351
}
44-
return { ...acc, [k]: { ...enMessagesToAdd[k], defaultMessage: acc[k].defaultMessage } };
52+
return {
53+
...acc,
54+
[k]: { ...enMessagesToAdd[k], defaultMessage: acc[k].defaultMessage },
55+
};
4556
}, {});
4657
};
4758
const getFileJSONContent = (filepath) => JSON.parse(fs.readFileSync(filepath));
4859

4960
const args = process.argv.slice(2);
50-
if (args.length === 0 || args.length > 2) {
51-
console.log(`Error: 2 arguments needed.
52-
1. Path to CreateAI tool translation strings directory.
53-
2. Path to machine-learning-strings.json translation strings directory. `);
61+
if (args.length !== 1) {
62+
console.log("Error: Missing argument to extracted Crowdin ZIP");
5463
process.exit(errExitStatus);
5564
}
5665

57-
const [createAiTranslationsFilepath, mlTranslationsFilepath] =
58-
args.length === 1 ? [args[0], null] : args;
66+
const prefix = args[0];
67+
const createAiStringsDir = "new/apps/microbit-createai";
68+
const extensionStringsDir = "new/makecode-extensions/pxt-microbit-ml";
5969

6070
languages.forEach((language) => {
6171
const lowerLang = language.toLowerCase();
@@ -71,18 +81,13 @@ languages.forEach((language) => {
7181
return;
7282
}
7383

74-
const srcLangFilepath = !createAiTranslationsFilepath
75-
? `lang/ui.${lowerLang}.json`
76-
: `${createAiTranslationsFilepath}/${language}/ui.en.json`;
84+
const srcLangFilepath = `${prefix}/${lowerLang}/${createAiStringsDir}/ui.en.json`;
7785
const langMessages = getFileJSONContent(srcLangFilepath);
7886

7987
// Update machine learning strings.
80-
let messagesToAdd = {}
81-
if (mlTranslationsFilepath) {
82-
const mlFilepath = `${mlTranslationsFilepath}/${language}/machine-learning-strings.json`;
83-
const mlStrings = getFileJSONContent(mlFilepath);
84-
messagesToAdd = getMessagesToAdd(mlStrings, langMessages);
85-
}
88+
const mlFilepath = `${prefix}/${lowerLang}/${extensionStringsDir}/machine-learning-strings.json`;
89+
const mlStrings = getFileJSONContent(mlFilepath);
90+
const messagesToAdd = getMessagesToAdd(mlStrings, langMessages);
8691

8792
fs.writeFileSync(
8893
outputFilepath,

lang/ui.ca.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,7 @@
715715
"defaultMessage": "Comencem",
716716
"description": "Get started action"
717717
},
718-
"go-action": {
719-
"defaultMessage": "Ves",
720-
"description": "Go action"
721-
},
718+
"go-action": { "defaultMessage": "Ves", "description": "Go action" },
722719
"graph-color-scheme": {
723720
"defaultMessage": "Esquema de colors del gràfic",
724721
"description": "Graph colour scheme setting label"
@@ -872,11 +869,11 @@
872869
"description": "Language option text"
873870
},
874871
"language-fully-supported-heading": {
875-
"defaultMessage": "Fully supported",
872+
"defaultMessage": "Completament compatible",
876873
"description": "Fully supported languages heading text"
877874
},
878875
"language-partially-supported-heading": {
879-
"defaultMessage": "Partially supported",
876+
"defaultMessage": "Parcialment compatible",
880877
"description": "Partially supported languages heading text"
881878
},
882879
"language-support-checked": {
@@ -1715,4 +1712,4 @@
17151712
"defaultMessage": "desconnecta i torna a connectar el cable USB",
17161713
"description": "WebUSB error dialog"
17171714
}
1718-
}
1715+
}

lang/ui.en.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,7 @@
715715
"defaultMessage": "Get started",
716716
"description": "Get started action"
717717
},
718-
"go-action": {
719-
"defaultMessage": "Go",
720-
"description": "Go action"
721-
},
718+
"go-action": { "defaultMessage": "Go", "description": "Go action" },
722719
"graph-color-scheme": {
723720
"defaultMessage": "Graph colour scheme",
724721
"description": "Graph colour scheme setting label"
@@ -1715,4 +1712,4 @@
17151712
"defaultMessage": "unplug and replug the USB cable",
17161713
"description": "WebUSB error dialog"
17171714
}
1718-
}
1715+
}

lang/ui.es-es.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,7 @@
715715
"defaultMessage": "Empieza",
716716
"description": "Get started action"
717717
},
718-
"go-action": {
719-
"defaultMessage": "Ir",
720-
"description": "Go action"
721-
},
718+
"go-action": { "defaultMessage": "Ir", "description": "Go action" },
722719
"graph-color-scheme": {
723720
"defaultMessage": "Esquema de colores del gráfico",
724721
"description": "Graph colour scheme setting label"
@@ -872,27 +869,27 @@
872869
"description": "Language option text"
873870
},
874871
"language-fully-supported-heading": {
875-
"defaultMessage": "Fully supported",
872+
"defaultMessage": "Totalmente compatible",
876873
"description": "Fully supported languages heading text"
877874
},
878875
"language-partially-supported-heading": {
879-
"defaultMessage": "Partially supported",
876+
"defaultMessage": "Parcialmente compatible",
880877
"description": "Partially supported languages heading text"
881878
},
882879
"language-support-checked": {
883-
"defaultMessage": "Admitidas",
880+
"defaultMessage": "Compatible",
884881
"description": "Aria label for ticked checkbox for language support"
885882
},
886883
"language-support-unchecked": {
887-
"defaultMessage": "No admitidas",
884+
"defaultMessage": "No compatible",
888885
"description": "Aria label for unticked checkbox for language support"
889886
},
890887
"language-supported-for": {
891-
"defaultMessage": "Traducciones admitidas para:",
888+
"defaultMessage": "Traducciones compatibles con:",
892889
"description": "Text introducing list of translated areas for a given language (areas: Microsoft MakeCode, micro:bit CreateAI UI itself)"
893890
},
894891
"language-toast-title": {
895-
"defaultMessage": "El idioma no es soportado totalmente",
892+
"defaultMessage": "Idioma no es totalmente compatible",
896893
"description": "Language support toast notification title"
897894
},
898895
"learn-about-firewall-requirements-action": {
@@ -1715,4 +1712,4 @@
17151712
"defaultMessage": "desenchufa y vuelve a enchufar el cable USB",
17161713
"description": "WebUSB error dialog"
17171714
}
1718-
}
1715+
}

0 commit comments

Comments
 (0)