Skip to content

Commit 45032cc

Browse files
committed
Add translation to missing strings
Question, should ‘x’ and ‘y’ be localizable?
1 parent 54c5bae commit 45032cc

File tree

13 files changed

+193
-44
lines changed

13 files changed

+193
-44
lines changed

.tx/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[main]
22
host = https://www.transifex.com
33

4-
[experimental-scratch.scratch-gui]
4+
[scratch-editor.interface]
55
file_filter = translations/<lang>.json
66
source_file = translations/en.json
77
source_lang = en

src/components/controls/controls.jsx

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
import classNames from 'classnames';
22
import PropTypes from 'prop-types';
33
import React from 'react';
4+
import {defineMessages, injectIntl, intlShape} from 'react-intl';
45

56
import GreenFlag from '../green-flag/green-flag.jsx';
67
import StopAll from '../stop-all/stop-all.jsx';
78
import TurboMode from '../turbo-mode/turbo-mode.jsx';
89

910
import styles from './controls.css';
1011

12+
const messages = defineMessages({
13+
goTitle: {
14+
id: 'gui.controls.go',
15+
defaultMessage: 'Go',
16+
description: 'Green flag button title'
17+
},
18+
stopTitle: {
19+
id: 'gui.controls.stop',
20+
defaultMessage: 'Stop',
21+
description: 'Stop button title'
22+
}
23+
});
24+
1125
const Controls = function (props) {
1226
const {
1327
active,
1428
className,
29+
intl,
1530
onGreenFlagClick,
1631
onStopAllClick,
1732
turbo,
@@ -24,10 +39,12 @@ const Controls = function (props) {
2439
>
2540
<GreenFlag
2641
active={active}
42+
title={intl.formatMessage(messages.goTitle)}
2743
onClick={onGreenFlagClick}
2844
/>
2945
<StopAll
3046
active={active}
47+
title={intl.formatMessage(messages.stopTitle)}
3148
onClick={onStopAllClick}
3249
/>
3350
{turbo ? (
@@ -40,6 +57,7 @@ const Controls = function (props) {
4057
Controls.propTypes = {
4158
active: PropTypes.bool,
4259
className: PropTypes.string,
60+
intl: intlShape.isRequired,
4361
onGreenFlagClick: PropTypes.func.isRequired,
4462
onStopAllClick: PropTypes.func.isRequired,
4563
turbo: PropTypes.bool
@@ -50,4 +68,4 @@ Controls.defaultProps = {
5068
turbo: false
5169
};
5270

53-
export default Controls;
71+
export default injectIntl(Controls);

src/components/crash-message/crash-message.jsx

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import Box from '../box/box.jsx';
4+
import {FormattedMessage} from 'react-intl';
45

56
import styles from './crash-message.css';
67
import reloadIcon from './reload.svg';
@@ -13,13 +14,20 @@ const CrashMessage = props => (
1314
src={reloadIcon}
1415
/>
1516
<h2>
16-
Oops! Something went wrong.
17+
<FormattedMessage
18+
defaultMessage="Oops! Something went wrong."
19+
description="Unhandled error title"
20+
id="gui.crashMessage.title"
21+
/>
1722
</h2>
1823
<p>
19-
We are so sorry, but it looks like Scratch has crashed. This bug has been
20-
automatically reported to the Scratch Team. Please refresh your page to try
21-
again.
22-
24+
{ /* eslint-disable max-len */ }
25+
<FormattedMessage
26+
defaultMessage="We are so sorry, but it looks like Scratch has crashed. This bug has been automatically reported to the Scratch Team. Please refresh your page to try again."
27+
description="Unhandled error description"
28+
id="gui.crashMessage.description"
29+
/>
30+
{ /* eslint-enable max-len */ }
2331
</p>
2432
<button
2533
className={styles.reloadButton}

src/components/forms/label.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Label = props => (
1515
Label.propTypes = {
1616
children: PropTypes.node,
1717
secondary: PropTypes.bool,
18-
text: PropTypes.string.isRequired
18+
text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired
1919
};
2020

2121
Label.defaultProps = {

src/components/library/library.jsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import classNames from 'classnames';
22
import bindAll from 'lodash.bindall';
33
import PropTypes from 'prop-types';
44
import React from 'react';
5+
import {defineMessages, injectIntl, intlShape} from 'react-intl';
56

67
import LibraryItem from '../library-item/library-item.jsx';
78
import Modal from '../../containers/modal.jsx';
@@ -14,6 +15,14 @@ import styles from './library.css';
1415
const ALL_TAG_TITLE = 'All';
1516
const tagListPrefix = [{title: ALL_TAG_TITLE}];
1617

18+
const messages = defineMessages({
19+
filterPlaceholder: {
20+
id: 'gui.library.filterPlaceholder',
21+
defaultMessage: 'Search',
22+
description: 'Placeholder text for library search field'
23+
}
24+
});
25+
1726
class LibraryComponent extends React.Component {
1827
constructor (props) {
1928
super(props);
@@ -101,6 +110,7 @@ class LibraryComponent extends React.Component {
101110
)}
102111
filterQuery={this.state.filterQuery}
103112
inputClassName={styles.filterInput}
113+
placeholderText={this.props.intl.formatMessage(messages.filterPlaceholder)}
104114
onChange={this.handleFilterChange}
105115
onClear={this.handleFilterClear}
106116
/>
@@ -176,6 +186,7 @@ LibraryComponent.propTypes = {
176186
),
177187
filterable: PropTypes.bool,
178188
id: PropTypes.string.isRequired,
189+
intl: intlShape.isRequired,
179190
onItemMouseEnter: PropTypes.func,
180191
onItemMouseLeave: PropTypes.func,
181192
onItemSelected: PropTypes.func,
@@ -188,4 +199,4 @@ LibraryComponent.defaultProps = {
188199
filterable: true
189200
};
190201

191-
export default LibraryComponent;
202+
export default injectIntl(LibraryComponent);

src/components/modal/modal.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import classNames from 'classnames';
22
import PropTypes from 'prop-types';
33
import React from 'react';
44
import ReactModal from 'react-modal';
5+
import {FormattedMessage} from 'react-intl';
56

67
import Box from '../box/box.jsx';
78
import Button from '../button/button.jsx';
@@ -46,7 +47,11 @@ const ModalComponent = props => (
4647
iconSrc={backIcon}
4748
onClick={props.onRequestClose}
4849
>
49-
Back
50+
<FormattedMessage
51+
defaultMessage="Back"
52+
description="Back button in modal"
53+
id="gui.modal.back"
54+
/>
5055
</Button>
5156
) : (
5257
<CloseButton

src/components/record-modal/playback-step.jsx

+34-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,36 @@ import Box from '../box/box.jsx';
44
import Waveform from '../waveform/waveform.jsx';
55
import Meter from '../meter/meter.jsx';
66
import AudioTrimmer from '../../containers/audio-trimmer.jsx';
7+
import {defineMessages, injectIntl, intlShape} from 'react-intl';
78

89
import styles from './record-modal.css';
910
import backIcon from './icon--back.svg';
1011
import stopIcon from './icon--stop-playback.svg';
1112
import playIcon from './icon--play.svg';
1213

14+
const messages = defineMessages({
15+
stopMsg: {
16+
defaultMessage: 'Stop',
17+
description: 'Stop/Play button in recording playback',
18+
id: 'gui.playbackStep.stopMsg'
19+
},
20+
playMsg: {
21+
defaultMessage: 'Play',
22+
description: 'Stop/Play button in recording playback',
23+
id: 'gui.playbackStep.playMsg'
24+
},
25+
loadingMsg: {
26+
defaultMessage: 'Loading...',
27+
description: 'Loading/Save button in recording playback',
28+
id: 'gui.playbackStep.loadingMsg'
29+
},
30+
saveMsg: {
31+
defaultMessage: 'Save',
32+
description: 'Loading/Save button in recording playback',
33+
id: 'gui.playbackStep.saveMsg'
34+
}
35+
});
36+
1337
const PlaybackStep = props => (
1438
<Box>
1539
<Box className={styles.visualizationContainer}>
@@ -48,7 +72,10 @@ const PlaybackStep = props => (
4872
/>
4973
<div className={styles.helpText}>
5074
<span className={styles.playingText}>
51-
{props.playing ? 'Stop' : 'Play'}
75+
{props.playing ?
76+
props.intl.formatMessage(messages.stopMsg) :
77+
props.intl.formatMessage(messages.playMsg)
78+
}
5279
</span>
5380
</div>
5481
</button>
@@ -68,14 +95,18 @@ const PlaybackStep = props => (
6895
disabled={props.encoding}
6996
onClick={props.onSubmit}
7097
>
71-
{props.encoding ? 'Loading...' : 'Save'}
98+
{props.encoding ?
99+
props.intl.formatMessage(messages.loadingMsg) :
100+
props.intl.formatMessage(messages.saveMsg)
101+
}
72102
</button>
73103
</Box>
74104
</Box>
75105
);
76106

77107
PlaybackStep.propTypes = {
78108
encoding: PropTypes.bool.isRequired,
109+
intl: intlShape.isRequired,
79110
levels: PropTypes.arrayOf(PropTypes.number).isRequired,
80111
onBack: PropTypes.func.isRequired,
81112
onPlay: PropTypes.func.isRequired,
@@ -89,4 +120,4 @@ PlaybackStep.propTypes = {
89120
trimStart: PropTypes.number.isRequired
90121
};
91122

92-
export default PlaybackStep;
123+
export default injectIntl(PlaybackStep);

src/components/record-modal/record-modal.jsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import Box from '../box/box.jsx';
4+
import {defineMessages, injectIntl, intlShape} from 'react-intl';
45
import RecordingStep from '../../containers/recording-step.jsx';
56
import PlaybackStep from '../../containers/playback-step.jsx';
67
import Modal from '../modal/modal.jsx';
78
import styles from './record-modal.css';
89

10+
const messages = defineMessages({
11+
title: {
12+
defaultMessage: 'Record Sound',
13+
description: 'Recording modal title',
14+
id: 'gui.recordModal.title'
15+
}
16+
});
17+
918
const RecordModal = props => (
1019
<Modal
1120
className={styles.modalContent}
12-
contentLabel={'Record Sound'}
21+
contentLabel={props.intl.formatMessage(messages.title)}
1322
onRequestClose={props.onCancel}
1423
>
1524
<Box className={styles.body}>
@@ -44,6 +53,7 @@ const RecordModal = props => (
4453

4554
RecordModal.propTypes = {
4655
encoding: PropTypes.bool.isRequired,
56+
intl: intlShape.isRequired,
4757
levels: PropTypes.arrayOf(PropTypes.number),
4858
onBack: PropTypes.func.isRequired,
4959
onCancel: PropTypes.func.isRequired,
@@ -64,4 +74,4 @@ RecordModal.propTypes = {
6474
trimStart: PropTypes.number.isRequired
6575
};
6676

67-
export default RecordModal;
77+
export default injectIntl(RecordModal);

src/components/sprite-info/sprite-info.jsx

+43-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Box from '../box/box.jsx';
77
import Label from '../forms/label.jsx';
88
import Input from '../forms/input.jsx';
99
import BufferedInputHOC from '../forms/buffered-input-hoc.jsx';
10+
import {FormattedMessage} from 'react-intl';
1011

1112
import layout from '../../lib/layout-constants.js';
1213
import styles from './sprite-info.css';
@@ -31,17 +32,52 @@ class SpriteInfo extends React.Component {
3132
);
3233
}
3334
render () {
35+
const sprite = (
36+
<FormattedMessage
37+
defaultMessage="Sprite"
38+
description="Sprite info label"
39+
id="gui.SpriteInfo.sprite"
40+
/>
41+
);
42+
const spritePlaceholder = (
43+
<FormattedMessage
44+
defaultMessage="Name"
45+
description="Placeholder text for sprite name"
46+
id="gui.SpriteInfo.spritePlaceholder"
47+
/>
48+
);
49+
const showLabel = (
50+
<FormattedMessage
51+
defaultMessage="Show"
52+
description="Sprite info show label"
53+
id="gui.SpriteInfo.show"
54+
/>
55+
);
56+
const sizeLabel = (
57+
<FormattedMessage
58+
defaultMessage="Size"
59+
description="Sprite info size label"
60+
id="gui.SpriteInfo.size"
61+
/>
62+
);
63+
const directionLabel = (
64+
<FormattedMessage
65+
defaultMessage="Direction"
66+
description="Sprite info direction label"
67+
id="gui.SpriteInfo.direction"
68+
/>
69+
);
3470
return (
3571
<Box
3672
className={styles.spriteInfo}
3773
>
3874
<div className={classNames(styles.row, styles.rowPrimary)}>
3975
<div className={styles.group}>
40-
<Label text="Sprite">
76+
<Label text={sprite}>
4177
<BufferedInput
4278
className={styles.spriteInput}
4379
disabled={this.props.disabled}
44-
placeholder="Name"
80+
placeholder={spritePlaceholder}
4581
tabIndex="0"
4682
type="text"
4783
value={this.props.disabled ? '' : this.props.name}
@@ -102,7 +138,7 @@ class SpriteInfo extends React.Component {
102138
<MediaQuery minWidth={layout.fullSizeMinWidth}>
103139
<Label
104140
secondary
105-
text="Show"
141+
text={showLabel}
106142
/>
107143
</MediaQuery>
108144
<div>
@@ -149,12 +185,12 @@ class SpriteInfo extends React.Component {
149185
<div className={classNames(styles.group, styles.largerInput)}>
150186
<Label
151187
secondary
152-
text="Size"
188+
text={sizeLabel}
153189
>
154190
<BufferedInput
155191
small
156192
disabled={this.props.disabled}
157-
label="Size"
193+
label={sizeLabel}
158194
tabIndex="0"
159195
type="text"
160196
value={this.props.disabled ? '' : this.props.size}
@@ -165,12 +201,12 @@ class SpriteInfo extends React.Component {
165201
<div className={classNames(styles.group, styles.largerInput)}>
166202
<Label
167203
secondary
168-
text="Direction"
204+
text={directionLabel}
169205
>
170206
<BufferedInput
171207
small
172208
disabled={this.props.disabled}
173-
label="Direction"
209+
label={directionLabel}
174210
tabIndex="0"
175211
type="text"
176212
value={this.props.disabled ? '' : this.props.direction}

0 commit comments

Comments
 (0)