Skip to content
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2fda172
Minimal Viable Navigation Menu
oruburos Jul 22, 2020
8f90cf7
Minimal Viable Navigation Menu
oruburos Jul 22, 2020
fc7e3cd
Translation.json : Changes in translation for new namespace
oruburos Jul 23, 2020
02e6cef
Voice Over Labels in Preferences:index
oruburos Jul 23, 2020
11145cc
Voice Over Labels in Preferences:index
oruburos Jul 27, 2020
11941b7
Voice Over Labels in Preferences:index
oruburos Jul 27, 2020
63d2913
Voice Over Labels in Preferences:index
oruburos Jul 27, 2020
b3606c9
translations.json ARIA labels adjacent to respective label
oruburos Jul 28, 2020
3bce95c
Merge remote-tracking branch 'remotes/upstream/develop' into minimal_nav
oruburos Jul 28, 2020
2fc71c1
Update Nav.jsx
oruburos Jul 30, 2020
1e809a9
Update Toolbar.test.jsx
oruburos Jul 30, 2020
118741a
Update in keys
oruburos Jul 30, 2020
eca1d3b
Merge branch 'minimal_nav' of https://github.com/oruburos/p5.js-web-e…
oruburos Jul 30, 2020
563f296
Merge branch 'develop' into minimal_nav
andrewn Jul 31, 2020
da14c10
Jest test v2
oruburos Aug 4, 2020
8877f5f
Jest test v3
oruburos Aug 4, 2020
6a077d6
Toolbar test entries for Toolbar
oruburos Aug 4, 2020
bd0a266
Merge remote-tracking branch 'origin/minimal_nav' into minimal_nav_2
oruburos Aug 6, 2020
b1d75f9
Merge remote-tracking branch 'remotes/upstream/develop' into minimal_…
oruburos Aug 6, 2020
cfab815
Merge remote-tracking branch 'remotes/upstream/develop' into minimal_…
oruburos Aug 7, 2020
73b314f
Aria labels in toolbar
oruburos Aug 7, 2020
270337e
Toolbar using props t.
oruburos Aug 11, 2020
3253458
Toolbar using props t.
oruburos Aug 11, 2020
eb7741f
Merge branch 'develop' into minimal_nav
andrewn Aug 13, 2020
3cb1b9a
Merge branch 'develop' into minimal_nav
andrewn Aug 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions client/i18n-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import i18n from 'i18next';
import translationEnglish from '../translations/locales/en-US/translations.json';

i18n
.init({
fallbackLng: 'en',
lng: 'en-US',
ns: ['translations'],
defaultNS: ['translations'],
debug: false,
saveMissing: false,
interpolation: {
escapeValue: false, // react already safes from xss
},
resources: {
en: {
translations: translationEnglish
}
},
react: {
wait: false,
nsMode: 'fallback'
}
});
export default i18n;
19 changes: 9 additions & 10 deletions client/modules/IDE/components/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import { Link } from 'react-router';
import classNames from 'classnames';
import { withTranslation } from 'react-i18next';
import i18n from 'i18next';
import * as IDEActions from '../actions/ide';
import * as preferenceActions from '../actions/preferences';
import * as projectActions from '../actions/project';
Expand Down Expand Up @@ -86,23 +87,23 @@ class Toolbar extends React.Component {
this.props.setTextOutput(true);
this.props.setGridOutput(true);
}}
aria-label="Play sketch"
aria-label={i18n.t('Toolbar.PlaySketchARIA')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use withTranslation() here. The react-i18next documentation doesn't mention the method you're using here at all which makes me concerned about using it.

All of these can be this.props.t('...')

disabled={this.props.infiniteLoop}
>
<PlayIcon focusable="false" aria-hidden="true" />
</button>
<button
className={playButtonClass}
onClick={this.props.startSketch}
aria-label="Play only visual sketch"
aria-label={i18n.t('Toolbar.PlayOnlyVisualSketchARIA')}
disabled={this.props.infiniteLoop}
>
<PlayIcon focusable="false" aria-hidden="true" />
</button>
<button
className={stopButtonClass}
onClick={this.props.stopSketch}
aria-label="Stop sketch"
aria-label={i18n.t('Toolbar.StopSketchARIA')}
>
<StopIcon focusable="false" aria-hidden="true" />
</button>
Expand All @@ -116,7 +117,7 @@ class Toolbar extends React.Component {
}}
/>
<label htmlFor="autorefresh" className="toolbar__autorefresh-label">
{this.props.t('Toolbar.Auto-refresh')}
{i18n.t('Toolbar.Auto-refresh')}
</label>
</div>
<div className={nameContainerClass}>
Expand All @@ -129,7 +130,7 @@ class Toolbar extends React.Component {
}
}}
disabled={!canEditProjectName}
aria-label="Edit sketch name"
aria-label={i18n.t('Toolbar.EditSketchARIA')}
>
<span>{this.props.project.name}</span>
{
Expand All @@ -145,7 +146,7 @@ class Toolbar extends React.Component {
type="text"
maxLength="128"
className="toolbar__project-name-input"
aria-label="New sketch name"
aria-label={i18n.t('Toolbar.NewSketchNameARIA')}
value={this.state.projectNameInputValue}
onChange={this.handleProjectNameChange}
ref={(element) => { this.projectNameInput = element; }}
Expand All @@ -165,7 +166,7 @@ class Toolbar extends React.Component {
<button
className={preferencesButtonClass}
onClick={this.props.openPreferences}
aria-label="Open Preferences"
aria-label={i18n.t('Toolbar.OpenPreferencesARIA')}
>
<PreferencesIcon focusable="false" aria-hidden="true" />
</button>
Expand Down Expand Up @@ -198,8 +199,7 @@ Toolbar.propTypes = {
startSketch: PropTypes.func.isRequired,
startAccessibleSketch: PropTypes.func.isRequired,
saveProject: PropTypes.func.isRequired,
currentUser: PropTypes.string,
t: PropTypes.func.isRequired
currentUser: PropTypes.string
};

Toolbar.defaultProps = {
Expand All @@ -226,5 +226,4 @@ const mapDispatchToProps = {
};

export const ToolbarComponent = Toolbar;
// export default connect(mapStateToProps, mapDispatchToProps)(Toolbar);
export default withTranslation()(connect(mapStateToProps, mapDispatchToProps)(Toolbar));
3 changes: 1 addition & 2 deletions client/modules/IDE/components/Toolbar.test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import lodash from 'lodash';


import { ToolbarComponent } from './Toolbar';
import { i18ntest } from '../../../i18n-test';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not using the i18ntest variable, then there's no need to assign it here. You can just do this:

import '../../../i18n-test';


const renderComponent = (extraProps = {}) => {
const props = lodash.merge({
Expand Down