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 file_filter = gui/<lang>.json
source_file = gui/en.json source_file = gui/en.json
source_lang = en source_lang = en
type = CHROME
[experimental-scratch.scratch-paint]
file_filter = paint/<lang>.json
source_file = paint/en.json
source_lang = en
type = CHROME type = CHROME

View file

@ -1,6 +1,6 @@
{ {
"name": "scratch-l10n", "name": "scratch-l10n",
"version": "1.0.0", "version": "2.0.0",
"description": "Localization for the Scratch 3.0 components", "description": "Localization for the Scratch 3.0 components",
"main": "./dist/l10n.js", "main": "./dist/l10n.js",
"scripts": { "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/'; const MSGS_DIR = './locales/';
let missingLocales = []; let missingLocales = [];
// GUI messages: // generate messages:
let component = 'gui'; let components = ['gui', 'paint'];
let messages = Object.keys(locales).reduce((collection, lang) => { components.forEach((component) => {
let langMessages = {}; let messages = Object.keys(locales).reduce((collection, lang) => {
try { let langMessages = {};
let langData = JSON.parse( try {
fs.readFileSync(path.resolve(component, lang + '.json'), 'utf8') let langData = JSON.parse(
); fs.readFileSync(path.resolve(component, lang + '.json'), 'utf8')
Object.keys(langData).forEach((id) => { );
langMessages[id] = langData[id].message; Object.keys(langData).forEach((id) => {
}); langMessages[id] = langData[id].message;
collection[lang] = { });
name: locales[lang], collection[lang] = {
messages: langMessages messages: langMessages
}; };
} catch (e) { } catch (e) {
missingLocales.push(lang); 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 de from 'react-intl/locale-data/de';
import es from 'react-intl/locale-data/es'; import es from 'react-intl/locale-data/es';
import he from 'react-intl/locale-data/he'; import he from 'react-intl/locale-data/he';
import locales from './supported-locales.js';
import {locales} from '../locales/gui-msgs.js'; let localeData = locales;
localeData.en.localeData = en;
locales.en.localeData = en; localeData.ar.localeData = ar;
locales.ar.localeData = ar; localeData.de.localeData = de;
locales.de.localeData = de; localeData.es.localeData = es;
locales.es.localeData = es; localeData.he.localeData = he;
locales.he.localeData = he;
export { export {
locales as default localeData as default
}; };

View file

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