Merge pull request #6 from chrisgarrity/feature/add-paint

Change scratch-l10n structure to support translations from multiple components, and add scratch-paint.
This commit is contained in:
chrisgarrity 2017-10-19 08:29:48 -04:00 committed by GitHub
commit 782c4498a2
10 changed files with 362 additions and 46 deletions

View file

@ -5,4 +5,9 @@ host = https://www.transifex.com
file_filter = gui/<lang>.json
source_file = gui/en.json
source_lang = en
type = CHROME
[experimental-scratch.scratch-paint]
file_filter = paint/<lang>.json
source_file = paint/en.json
source_lang = en
type = CHROME

View file

@ -1,6 +1,6 @@
{
"name": "scratch-l10n",
"version": "1.0.0",
"version": "2.0.0",
"description": "Localization for the Scratch 3.0 components",
"main": "./dist/l10n.js",
"scripts": {

62
paint/ar.json Normal file
View file

@ -0,0 +1,62 @@
{
"paint.paintEditor.fill": {
"message": "Fill",
"description": "Label for the color picker for the fill color"
},
"paint.eraserMode.eraser": {
"message": "Eraser",
"description": "Label for the eraser tool"
},
"paint.penMode.pen": {
"message": "Pen",
"description": "Label for the pen tool, which draws outlines"
},
"paint.paintEditor.saturation": {
"message": "Saturation",
"description": "Label for the saturation component in the color picker"
},
"paint.roundedRectMode.roundedRect": {
"message": "Rounded Rectangle",
"description": "Label for the rounded rectangle tool"
},
"paint.brushMode.brush": {
"message": "Brush",
"description": "Label for the brush tool"
},
"paint.lineMode.line": {
"message": "Line",
"description": "Label for the line tool, which draws straight line segments"
},
"paint.reshapeMode.reshape": {
"message": "Reshape",
"description": "Label for the reshape tool, which allows changing the points in the lines of the vectors"
},
"paint.paintEditor.brightness": {
"message": "Brightness",
"description": "Label for the brightness component in the color picker"
},
"paint.paintEditor.costume": {
"message": "Costume",
"description": "Label for the name of a sound"
},
"paint.rectMode.rect": {
"message": "Rectangle",
"description": "Label for the rectangle tool"
},
"paint.ovalMode.oval": {
"message": "Circle",
"description": "Label for the oval-drawing tool"
},
"paint.paintEditor.hue": {
"message": "Hue",
"description": "Label for the hue component in the color picker"
},
"paint.paintEditor.stroke": {
"message": "Outline",
"description": "Label for the color picker for the outline color"
},
"paint.selectMode.select": {
"message": "Select",
"description": "Label for the select tool, which allows selecting, moving, and resizing shapes"
}
}

62
paint/de.json Normal file
View file

@ -0,0 +1,62 @@
{
"paint.paintEditor.fill": {
"message": "Fill",
"description": "Label for the color picker for the fill color"
},
"paint.eraserMode.eraser": {
"message": "Eraser",
"description": "Label for the eraser tool"
},
"paint.penMode.pen": {
"message": "Pen",
"description": "Label for the pen tool, which draws outlines"
},
"paint.paintEditor.saturation": {
"message": "Saturation",
"description": "Label for the saturation component in the color picker"
},
"paint.roundedRectMode.roundedRect": {
"message": "Rounded Rectangle",
"description": "Label for the rounded rectangle tool"
},
"paint.brushMode.brush": {
"message": "Brush",
"description": "Label for the brush tool"
},
"paint.lineMode.line": {
"message": "Line",
"description": "Label for the line tool, which draws straight line segments"
},
"paint.reshapeMode.reshape": {
"message": "Reshape",
"description": "Label for the reshape tool, which allows changing the points in the lines of the vectors"
},
"paint.paintEditor.brightness": {
"message": "Brightness",
"description": "Label for the brightness component in the color picker"
},
"paint.paintEditor.costume": {
"message": "Costume",
"description": "Label for the name of a sound"
},
"paint.rectMode.rect": {
"message": "Rectangle",
"description": "Label for the rectangle tool"
},
"paint.ovalMode.oval": {
"message": "Circle",
"description": "Label for the oval-drawing tool"
},
"paint.paintEditor.hue": {
"message": "Hue",
"description": "Label for the hue component in the color picker"
},
"paint.paintEditor.stroke": {
"message": "Outline",
"description": "Label for the color picker for the outline color"
},
"paint.selectMode.select": {
"message": "Select",
"description": "Label for the select tool, which allows selecting, moving, and resizing shapes"
}
}

62
paint/en.json Normal file
View file

@ -0,0 +1,62 @@
{
"paint.paintEditor.fill": {
"message": "Fill",
"description": "Label for the color picker for the fill color"
},
"paint.eraserMode.eraser": {
"message": "Eraser",
"description": "Label for the eraser tool"
},
"paint.penMode.pen": {
"message": "Pen",
"description": "Label for the pen tool, which draws outlines"
},
"paint.paintEditor.saturation": {
"message": "Saturation",
"description": "Label for the saturation component in the color picker"
},
"paint.roundedRectMode.roundedRect": {
"message": "Rounded Rectangle",
"description": "Label for the rounded rectangle tool"
},
"paint.brushMode.brush": {
"message": "Brush",
"description": "Label for the brush tool"
},
"paint.lineMode.line": {
"message": "Line",
"description": "Label for the line tool, which draws straight line segments"
},
"paint.reshapeMode.reshape": {
"message": "Reshape",
"description": "Label for the reshape tool, which allows changing the points in the lines of the vectors"
},
"paint.paintEditor.brightness": {
"message": "Brightness",
"description": "Label for the brightness component in the color picker"
},
"paint.paintEditor.costume": {
"message": "Costume",
"description": "Label for the name of a sound"
},
"paint.rectMode.rect": {
"message": "Rectangle",
"description": "Label for the rectangle tool"
},
"paint.ovalMode.oval": {
"message": "Circle",
"description": "Label for the oval-drawing tool"
},
"paint.paintEditor.hue": {
"message": "Hue",
"description": "Label for the hue component in the color picker"
},
"paint.paintEditor.stroke": {
"message": "Outline",
"description": "Label for the color picker for the outline color"
},
"paint.selectMode.select": {
"message": "Select",
"description": "Label for the select tool, which allows selecting, moving, and resizing shapes"
}
}

62
paint/es.json Normal file
View file

@ -0,0 +1,62 @@
{
"paint.paintEditor.fill": {
"message": "Fill",
"description": "Label for the color picker for the fill color"
},
"paint.eraserMode.eraser": {
"message": "Eraser",
"description": "Label for the eraser tool"
},
"paint.penMode.pen": {
"message": "Pen",
"description": "Label for the pen tool, which draws outlines"
},
"paint.paintEditor.saturation": {
"message": "Saturation",
"description": "Label for the saturation component in the color picker"
},
"paint.roundedRectMode.roundedRect": {
"message": "Rounded Rectangle",
"description": "Label for the rounded rectangle tool"
},
"paint.brushMode.brush": {
"message": "Brush",
"description": "Label for the brush tool"
},
"paint.lineMode.line": {
"message": "Line",
"description": "Label for the line tool, which draws straight line segments"
},
"paint.reshapeMode.reshape": {
"message": "Reshape",
"description": "Label for the reshape tool, which allows changing the points in the lines of the vectors"
},
"paint.paintEditor.brightness": {
"message": "Brightness",
"description": "Label for the brightness component in the color picker"
},
"paint.paintEditor.costume": {
"message": "Costume",
"description": "Label for the name of a sound"
},
"paint.rectMode.rect": {
"message": "Rectangle",
"description": "Label for the rectangle tool"
},
"paint.ovalMode.oval": {
"message": "Circle",
"description": "Label for the oval-drawing tool"
},
"paint.paintEditor.hue": {
"message": "Hue",
"description": "Label for the hue component in the color picker"
},
"paint.paintEditor.stroke": {
"message": "Outline",
"description": "Label for the color picker for the outline color"
},
"paint.selectMode.select": {
"message": "Select",
"description": "Label for the select tool, which allows selecting, moving, and resizing shapes"
}
}

62
paint/he.json Normal file
View file

@ -0,0 +1,62 @@
{
"paint.paintEditor.fill": {
"message": "Fill",
"description": "Label for the color picker for the fill color"
},
"paint.eraserMode.eraser": {
"message": "Eraser",
"description": "Label for the eraser tool"
},
"paint.penMode.pen": {
"message": "Pen",
"description": "Label for the pen tool, which draws outlines"
},
"paint.paintEditor.saturation": {
"message": "Saturation",
"description": "Label for the saturation component in the color picker"
},
"paint.roundedRectMode.roundedRect": {
"message": "Rounded Rectangle",
"description": "Label for the rounded rectangle tool"
},
"paint.brushMode.brush": {
"message": "Brush",
"description": "Label for the brush tool"
},
"paint.lineMode.line": {
"message": "Line",
"description": "Label for the line tool, which draws straight line segments"
},
"paint.reshapeMode.reshape": {
"message": "Reshape",
"description": "Label for the reshape tool, which allows changing the points in the lines of the vectors"
},
"paint.paintEditor.brightness": {
"message": "Brightness",
"description": "Label for the brightness component in the color picker"
},
"paint.paintEditor.costume": {
"message": "Costume",
"description": "Label for the name of a sound"
},
"paint.rectMode.rect": {
"message": "Rectangle",
"description": "Label for the rectangle tool"
},
"paint.ovalMode.oval": {
"message": "Circle",
"description": "Label for the oval-drawing tool"
},
"paint.paintEditor.hue": {
"message": "Hue",
"description": "Label for the hue component in the color picker"
},
"paint.paintEditor.stroke": {
"message": "Outline",
"description": "Label for the color picker for the outline color"
},
"paint.selectMode.select": {
"message": "Select",
"description": "Label for the select tool, which allows selecting, moving, and resizing shapes"
}
}

View file

@ -45,36 +45,37 @@ import locales from '../src/supported-locales.js';
const MSGS_DIR = './locales/';
let missingLocales = [];
// GUI messages:
let component = 'gui';
let messages = Object.keys(locales).reduce((collection, lang) => {
let langMessages = {};
try {
let langData = JSON.parse(
fs.readFileSync(path.resolve(component, lang + '.json'), 'utf8')
);
Object.keys(langData).forEach((id) => {
langMessages[id] = langData[id].message;
});
collection[lang] = {
name: locales[lang],
messages: langMessages
};
} catch (e) {
missingLocales.push(lang);
// generate messages:
let components = ['gui', 'paint'];
components.forEach((component) => {
let messages = Object.keys(locales).reduce((collection, lang) => {
let langMessages = {};
try {
let langData = JSON.parse(
fs.readFileSync(path.resolve(component, lang + '.json'), 'utf8')
);
Object.keys(langData).forEach((id) => {
langMessages[id] = langData[id].message;
});
collection[lang] = {
messages: langMessages
};
} catch (e) {
missingLocales.push(lang);
}
return collection;
}, {});
mkdirpSync(MSGS_DIR);
let data =
'// GENERATED FILE:\n' +
'const ' + component + 'Msgs = ' +
JSON.stringify(messages, null, 2) +
'\nexports.messages = ' + component + 'Msgs;\n';
fs.writeFileSync(MSGS_DIR + component + '-msgs.js', data);
if (missingLocales.length > 0) {
process.stdout.write('missing locales: ' + missingLocales.toString());
process.exit(1);
}
return collection;
}, {});
mkdirpSync(MSGS_DIR);
let data =
'// GENERATED FILE:\n' +
'const ' + component + 'Msgs = ' +
JSON.stringify(messages, null, 2) +
'\nexports.locales = ' + component + 'Msgs;\n';
fs.writeFileSync(MSGS_DIR + component + '-msgs.js', data);
if (missingLocales.length > 0) {
process.stdout.write('missing locales: ' + missingLocales.toString());
process.exit(1);
}
});

View file

@ -3,15 +3,15 @@ import ar from 'react-intl/locale-data/ar';
import de from 'react-intl/locale-data/de';
import es from 'react-intl/locale-data/es';
import he from 'react-intl/locale-data/he';
import locales from './supported-locales.js';
import {locales} from '../locales/gui-msgs.js';
locales.en.localeData = en;
locales.ar.localeData = ar;
locales.de.localeData = de;
locales.es.localeData = es;
locales.he.localeData = he;
let localeData = locales;
localeData.en.localeData = en;
localeData.ar.localeData = ar;
localeData.de.localeData = de;
localeData.es.localeData = es;
localeData.he.localeData = he;
export {
locales as default
localeData as default
};

View file

@ -4,11 +4,11 @@
*/
const locales = {
en: 'English',
ar: 'العربية',
de: 'Deutsch',
es: 'Español',
he: 'עִבְרִית'
en: {name: 'English'},
ar: {name: 'العربية'},
de: {name: 'Deutsch'},
es: {name: 'Español'},
he: {name: 'עִבְרִית'}
};
export {locales as default};