mirror of
https://github.com/scratchfoundation/scratch-l10n.git
synced 2024-12-22 21:52:35 -05:00
Merge pull request #94 from adroitwhiz/validate-extension-inputs
Validate extension input placeholders
This commit is contained in:
commit
5fb6b96f04
10 changed files with 105 additions and 19 deletions
|
@ -153,7 +153,7 @@
|
|||
"pen.penUp": "ብእር አንሳ",
|
||||
"pen.setColor": "የእስክሪብቶን ቀልም ወደ [COLOR] ለውጥ",
|
||||
"pen.setColorParam": "የእስክሪብቶን [COLOR_PARAM] ወደ [VALUE] ለውጥ",
|
||||
"pen.setHue": "የእስክሪብቶን ቀለም ወደ ለውጥ",
|
||||
"pen.setHue": "የእስክሪብቶን ቀለም ወደ [HUE] ለውጥ",
|
||||
"pen.setShade": "የእስክሪብቶን ጥቁረት ወደ [SHADE] ለውጥ",
|
||||
"pen.setSize": "የእስክሪብቶን ልክ ወደ [SIZE] ለውጥ",
|
||||
"pen.stamp": "ምልክት",
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
"gdxfor.getAcceleration": "תאוצה [DIRECTION]",
|
||||
"gdxfor.getForce": "כוח",
|
||||
"gdxfor.getSpin": "מהירות סיבוב [DIRECTION]",
|
||||
"gdxfor.getTilt": "זווית הטיה",
|
||||
"gdxfor.getTilt": "זווית הטיה [TILT]",
|
||||
"gdxfor.isFreeFalling": "נופל?",
|
||||
"gdxfor.isTilted": "מוטה",
|
||||
"gdxfor.isTilted": "מוטה [TILT]",
|
||||
"gdxfor.pulled": "נמשך",
|
||||
"gdxfor.pushed": "נדחף",
|
||||
"gdxfor.shaken": "נוער",
|
||||
|
@ -52,11 +52,11 @@
|
|||
"gdxfor.tiltDirectionMenu.front": "קדימה",
|
||||
"gdxfor.tiltDirectionMenu.left": "שמאלה",
|
||||
"gdxfor.tiltDirectionMenu.right": "ימינה",
|
||||
"gdxfor.turnedFaceDown": "turned face down",
|
||||
"gdxfor.turnedFaceUp": "turned face up",
|
||||
"gdxfor.turnedFaceDown": "פונה כלפי מטה",
|
||||
"gdxfor.turnedFaceUp": "פונה כלפי מעלה",
|
||||
"gdxfor.whenForcePushedOrPulled": "כאשר חיישן הכוח [PUSH_PULL]",
|
||||
"gdxfor.whenGesture": "כאשר [GESTURE]",
|
||||
"gdxfor.whenTilted": "כאשר מוטה",
|
||||
"gdxfor.whenTilted": "כאשר מוטה [TILT]",
|
||||
"makeymakey.downArrow": "חץ מטה",
|
||||
"makeymakey.downArrowShort": "מטה",
|
||||
"makeymakey.leftArrow": "חץ שמאלי",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"boost.color.white": "balta",
|
||||
"boost.color.yellow": "geltona",
|
||||
"boost.getMotorPosition": "variklio [MOTOR_REPORTER_ID] pozicija",
|
||||
"boost.getTiltAngle": "paversk kryptimi [NUSTATYTA_KRYPTIS]",
|
||||
"boost.getTiltAngle": "paversk kryptimi [TILT_DIRECTION]",
|
||||
"boost.motorDirection.backward": "šen",
|
||||
"boost.motorDirection.forward": "ten",
|
||||
"boost.motorDirection.reverse": "atvirkščiai",
|
||||
|
|
|
@ -40,9 +40,9 @@
|
|||
"gdxfor.getAcceleration": "aceleração [DIRECTION]",
|
||||
"gdxfor.getForce": "força",
|
||||
"gdxfor.getSpin": "velocidade de rotação [DIRECTION]",
|
||||
"gdxfor.getTilt": "inclinar ângulo",
|
||||
"gdxfor.getTilt": "inclinar ângulo [TILT]",
|
||||
"gdxfor.isFreeFalling": "caindo?",
|
||||
"gdxfor.isTilted": "intitulado",
|
||||
"gdxfor.isTilted": "intitulado [TILT]",
|
||||
"gdxfor.pulled": "puxado",
|
||||
"gdxfor.pushed": "empurrado",
|
||||
"gdxfor.shaken": "agitado",
|
||||
|
@ -56,7 +56,7 @@
|
|||
"gdxfor.turnedFaceUp": "virado para cima",
|
||||
"gdxfor.whenForcePushedOrPulled": "quando o sensor de força estiver sendo [PUSH_PULL]",
|
||||
"gdxfor.whenGesture": "quando [GESTURE]",
|
||||
"gdxfor.whenTilted": "quando intitulado",
|
||||
"gdxfor.whenTilted": "quando intitulado [TILT]",
|
||||
"makeymakey.downArrow": "seta para baixo",
|
||||
"makeymakey.downArrowShort": "baixo",
|
||||
"makeymakey.leftArrow": "seta para esquerda",
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
"gdxfor.tiltDirectionMenu.right": "правый",
|
||||
"gdxfor.turnedFaceDown": "повернут лицом вниз",
|
||||
"gdxfor.turnedFaceUp": "повернут лицом вверх",
|
||||
"gdxfor.whenForcePushedOrPulled": "когда датчик приложения силы [ТОЛКАТЬ_ТЯНУТЬ]",
|
||||
"gdxfor.whenForcePushedOrPulled": "когда датчик приложения силы [PUSH_PULL]",
|
||||
"gdxfor.whenGesture": "когда [GESTURE]",
|
||||
"gdxfor.whenTilted": "когда наклонён [TILT]",
|
||||
"makeymakey.downArrow": "стрелка вниз",
|
||||
|
@ -91,7 +91,7 @@
|
|||
"microbit.whenPinConnected": "когда подключён пин [PIN]",
|
||||
"microbit.whenTilted": "когда наклонён [DIRECTION]",
|
||||
"music.categoryName": "Музыка",
|
||||
"music.changeTempo": "изменить темп на [TEMP]",
|
||||
"music.changeTempo": "изменить темп на [TEMPO]",
|
||||
"music.drumBass": "(2) Большой барабан",
|
||||
"music.drumBongo": "(13) Бонго",
|
||||
"music.drumCabasa": "(15) Кабаса",
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
"boost.motorDirection.reverse": "teskari",
|
||||
"boost.motorOff": "motor [MOTOR_ID] ni ochiring",
|
||||
"boost.motorOn": "motor [MOTOR_ID] ni yoqing",
|
||||
"boost.motorOnFor": "motorni [ MOTOR_ID] soniyalar [ DURATION] davomida aylantiring",
|
||||
"boost.motorOnForRotation": "motorni aylantiring [ MOTOR_ID] aylanishi [ ROTATION] uchun",
|
||||
"boost.motorOnFor": "motorni [MOTOR_ID] soniyalar [DURATION] davomida aylantiring",
|
||||
"boost.motorOnForRotation": "motorni aylantiring [MOTOR_ID] aylanishi [ROTATION] uchun",
|
||||
"boost.seeingColor": " [COLOR] rangdagi g'ishtni ko'ryapsizmi?",
|
||||
"boost.setLightHue": "ochiq rangni [HUE] ga o'rnatish",
|
||||
"boost.setMotorDirection": "motorni joylashtirish [ MOTOR_ID] yo'nalishi [ MOTOR_ DIRECTION]",
|
||||
"boost.setMotorPower": "motorni [ MOTOR_ID] tezligini [ POWER] ga qo'ying",
|
||||
"boost.setMotorDirection": "motorni joylashtirish [MOTOR_ID] yo'nalishi [MOTOR_DIRECTION]",
|
||||
"boost.setMotorPower": "motorni [MOTOR_ID] tezligini [POWER] ga qo'ying",
|
||||
"boost.tiltDirection.any": "Hech narsa",
|
||||
"boost.tiltDirection.down": "pastga",
|
||||
"boost.tiltDirection.left": "chapga",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"boost.motorOff": "[MOTOR_ID] 停止",
|
||||
"boost.motorOn": "[MOTOR_ID] 啟動",
|
||||
"boost.motorOnFor": "[MOTOR_ID] 啟動 持續 [DURATION] 秒",
|
||||
"boost.motorOnForRotation": "[MOTOR_ID] 啟動 持續 [DURATION] 圈",
|
||||
"boost.motorOnForRotation": "[MOTOR_ID] 啟動 持續 [ROTATION] 圈",
|
||||
"boost.seeingColor": "看到顏色 [COLOR]?",
|
||||
"boost.setLightHue": "LED 顏色設為 [HUE]",
|
||||
"boost.setMotorDirection": "[MOTOR_ID] 方向設為 [MOTOR_DIRECTION]",
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"boost.motorOff": "Jikisa imoto [MOTOR_ID] Uyivale ",
|
||||
"boost.motorOn": "Jikisa imoto [MOTOR_ID] uyivule ",
|
||||
"boost.motorOnFor": "Jikisa imoto [MOTOR_ID] isikhathi [DURATION] imizuzwana ",
|
||||
"boost.motorOnForRotation": "Jikisa imoto[MOTOR_ID] Uku [ROTATIONS] Ukuphendukisa ",
|
||||
"boost.motorOnForRotation": "Jikisa imoto[MOTOR_ID] Uku [ROTATION] Ukuphendukisa ",
|
||||
"boost.seeingColor": "Ukubona [COLOR] Brick? ",
|
||||
"boost.setLightHue": "hlela ukhanya kombala ukuyise [HUE]",
|
||||
"boost.setMotorDirection": "lungisa imoto [MOTOR_ID] indlela [MOTOR_DIRECTION] ",
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
|
||||
"update": "scripts/update-translations.sh",
|
||||
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/",
|
||||
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/",
|
||||
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
|
||||
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
|
||||
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
|
||||
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
|
||||
|
|
86
scripts/validate-extension-inputs.js
Normal file
86
scripts/validate-extension-inputs.js
Normal file
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/env babel-node
|
||||
|
||||
/**
|
||||
* @fileoverview
|
||||
* Script to validate extension block input placeholders
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import async from 'async';
|
||||
import assert from 'assert';
|
||||
import locales from '../src/supported-locales.js';
|
||||
|
||||
// Globals
|
||||
const JSON_DIR = path.join(process.cwd(), '/editor/extensions');
|
||||
const source = JSON.parse(fs.readFileSync(`${JSON_DIR}/en.json`));
|
||||
|
||||
// Matches everything inside brackets, and the brackets themselves.
|
||||
// e.g. matches '[MOTOR_ID]', '[POWER]' from 'altera a potência de [MOTOR_ID] para [POWER]'
|
||||
const blockInputRegex = /\[.+?\]/g;
|
||||
|
||||
let numTotalErrors = 0;
|
||||
|
||||
const validateExtensionInputs = (translationData, locale) => {
|
||||
let numLocaleErrors = 0;
|
||||
for (const block of Object.keys(translationData)) {
|
||||
const englishBlockInputs = source[block].match(blockInputRegex);
|
||||
|
||||
if (!englishBlockInputs) continue;
|
||||
|
||||
// If null (meaning no matches), that means that English block inputs exist but translated ones don't.
|
||||
// Coerce it to an empty array so that the assertion below fails, instead of getting the less-helpful error
|
||||
// that we can't call Array.includes on null.
|
||||
const translatedBlockInputs = translationData[block].match(blockInputRegex) || [];
|
||||
|
||||
for (const input of englishBlockInputs) {
|
||||
// Currently there are enough errors here that it would be tedious to fix an error, rerun this tool
|
||||
// to find the next error, and repeat. So, catch the assertion error and add to the number of total errors.
|
||||
// This allows all errors to be displayed when the command is run, rather than just the first encountered.
|
||||
try {
|
||||
assert(
|
||||
translatedBlockInputs.includes(input),
|
||||
|
||||
`Block '${block}' in locale '${locale}' does not include input ${input}:\n` +
|
||||
translationData[block]
|
||||
);
|
||||
} catch (err) {
|
||||
numLocaleErrors++;
|
||||
console.error(err.message + '\n'); // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (numLocaleErrors > 0) {
|
||||
numTotalErrors += numLocaleErrors;
|
||||
throw new Error(`${numLocaleErrors} total error(s) for locale '${locale}'`);
|
||||
}
|
||||
};
|
||||
|
||||
const validate = (locale, callback) => {
|
||||
fs.readFile(`${JSON_DIR}/${locale}.json`, function (err, data) {
|
||||
if (err) callback(err);
|
||||
// let this throw an error if invalid json
|
||||
data = JSON.parse(data);
|
||||
|
||||
try {
|
||||
validateExtensionInputs(data, locale);
|
||||
} catch (error) {
|
||||
console.error(error.message + '\n'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
async.each(Object.keys(locales), validate, function (err) {
|
||||
if (err) {
|
||||
console.error(err); // eslint-disable-line no-console
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (numTotalErrors > 0) {
|
||||
console.error(`${numTotalErrors} total extension input error(s)`); // eslint-disable-line no-console
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue