Skip to content

Commit 12e5278

Browse files
committed
Merge branch 'feature/date-i18n' of https://github.com/andrewn/p5.js-web-editor into feature/date-i18n
2 parents 41eded5 + d725622 commit 12e5278

File tree

11 files changed

+109
-8
lines changed

11 files changed

+109
-8
lines changed

client/modules/IDE/components/CollectionList/CollectionList.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class CollectionList extends React.Component {
140140
{this._renderLoader()}
141141
{this._renderEmptyTable()}
142142
{this.hasCollections() &&
143-
<table className="sketches-table" summary="table containing all collections">
143+
<table className="sketches-table" summary={this.props.t('CollectionList.TableSummary')}>
144144
<thead>
145145
<tr>
146146
{this._renderFieldHeader('name', this.props.t('CollectionList.HeaderName'))}

client/modules/IDE/components/NewFileModal.jsx

+13
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,23 @@ class NewFileModal extends React.Component {
2020
constructor(props) {
2121
super(props);
2222
this.focusOnModal = this.focusOnModal.bind(this);
23+
this.handleOutsideClick = this.handleOutsideClick.bind(this);
2324
}
2425

2526
componentDidMount() {
2627
this.focusOnModal();
28+
document.addEventListener('click', this.handleOutsideClick, false);
29+
}
30+
31+
componentWillUnmount() {
32+
document.removeEventListener('click', this.handleOutsideClick, false);
33+
}
34+
35+
handleOutsideClick(e) {
36+
// ignore clicks on the component itself
37+
if (e.path.includes(this.modal)) return;
38+
39+
this.props.closeNewFileModal();
2740
}
2841

2942
focusOnModal() {

client/modules/IDE/components/NewFolderModal.jsx

+17
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@ import NewFolderForm from './NewFolderForm';
88
import ExitIcon from '../../../images/exit.svg';
99

1010
class NewFolderModal extends React.Component {
11+
constructor(props) {
12+
super(props);
13+
this.handleOutsideClick = this.handleOutsideClick.bind(this);
14+
}
15+
1116
componentDidMount() {
1217
this.newFolderModal.focus();
18+
document.addEventListener('click', this.handleOutsideClick, false);
19+
}
20+
21+
componentWillUnmount() {
22+
document.removeEventListener('click', this.handleOutsideClick, false);
23+
}
24+
25+
handleOutsideClick(e) {
26+
// ignore clicks on the component itself
27+
if (e.path.includes(this.newFolderModal)) return;
28+
29+
this.props.closeModal();
1330
}
1431

1532
render() {

client/modules/IDE/components/SketchList.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class SketchList extends React.Component {
433433
{this._renderLoader()}
434434
{this._renderEmptyTable()}
435435
{this.hasSketches() &&
436-
<table className="sketches-table" summary="table containing all saved projects">
436+
<table className="sketches-table" summary={this.props.t('SketchList.TableSummary')}>
437437
<thead>
438438
<tr>
439439
{this._renderFieldHeader('name', this.props.t('SketchList.HeaderName'))}

client/modules/IDE/components/Toolbar.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Toolbar extends React.Component {
156156
if (this.props.owner) {
157157
return (
158158
<p className="toolbar__project-owner">
159-
by <Link to={`/${this.props.owner.username}/sketches`}>{this.props.owner.username}</Link>
159+
{this.props.t('Toolbar.By')} <Link to={`/${this.props.owner.username}/sketches`}>{this.props.owner.username}</Link>
160160
</p>
161161
);
162162
}

client/modules/IDE/reducers/ide.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ const ide = (state = initialState, action) => {
4040
case ActionTypes.CONSOLE_EVENT:
4141
return Object.assign({}, state, { consoleEvent: action.event });
4242
case ActionTypes.SHOW_MODAL:
43-
return Object.assign({}, state, { modalIsVisible: true, parentId: action.parentId });
43+
return Object.assign({}, state, {
44+
modalIsVisible: true,
45+
parentId: action.parentId,
46+
newFolderModalVisible: false
47+
});
4448
case ActionTypes.HIDE_MODAL:
4549
return Object.assign({}, state, { modalIsVisible: false });
4650
case ActionTypes.COLLAPSE_SIDEBAR:
@@ -62,7 +66,11 @@ const ide = (state = initialState, action) => {
6266
case ActionTypes.CLOSE_PROJECT_OPTIONS:
6367
return Object.assign({}, state, { projectOptionsVisible: false });
6468
case ActionTypes.SHOW_NEW_FOLDER_MODAL:
65-
return Object.assign({}, state, { newFolderModalVisible: true, parentId: action.parentId });
69+
return Object.assign({}, state, {
70+
newFolderModalVisible: true,
71+
parentId: action.parentId,
72+
modalIsVisible: false
73+
});
6674
case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
6775
return Object.assign({}, state, { newFolderModalVisible: false });
6876
case ActionTypes.SHOW_SHARE_MODAL:

client/modules/User/components/Collection.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class Collection extends React.Component {
371371
<div className="collection-table-wrapper">
372372
{this._renderEmptyTable()}
373373
{this.hasCollectionItems() &&
374-
<table className="sketches-table" summary="table containing all collections">
374+
<table className="sketches-table" summary={this.props.t('Collection.TableSummary')}>
375375
<thead>
376376
<tr>
377377
{this._renderFieldHeader('name', this.props.t('Collection.HeaderName'))}

developer_docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This folder contains documents intended for developers of the p5.js Web Editor.
66
* [Development](development.md) - A guide for adding code to the web editor
77
* [Preparing a pull-request](preparing_a_pull_request.md) - Instructions for how to make a pull-request
88
* [Accessibility Guidelines](accessibility.md) - Guidelines for writing code to create an accessible application
9+
* [Translations Guidelines](translations.md) - Guidelines for translating the application
910
* [Deployment](deployment.md) - A guide to production deployment, and all platforms that are being used.
1011
* [Release](./release.md) - A guide to creating a production release.
1112

developer_docs/translations.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Translations Guidelines
2+
3+
4+
*How to contribute with Translations for p5 web editor*
5+
6+
## General rules of thumb for translations
7+
8+
In order to simplify the translations process the following rules of thumb were used:
9+
10+
## Technical Part
11+
12+
* There is only one file to translate all the texts in any specific language, which is located under the directory, in respective locale [subdirectory](https://github.com/processing/p5.js-web-editor/tree/develop/translations/locales)
13+
* The new language code must be added to [client/i18n.js](https://github.com/processing/p5.js-web-editor/blob/develop/client/i18n.js#L7)
14+
* New languages will need to be selected using a dropdown in Nav component, specifically in function [renderLanguageMenu.](https://github.com/processing/p5.js-web-editor/blob/develop/client/components/Nav.jsx#L550)
15+
16+
## Translations
17+
18+
* Every component should introduce its own subset of keys inside a dictionary named after the component.
19+
For instance: If you want to translate AssetList.jsx you need to introduce the following namespace in translations.json :
20+
```json
21+
"AssetList": {
22+
"Title": "p5.js Web Editor | My assets",
23+
"ToggleOpenCloseARIA": "Toggle Open/Close Asset Options",
24+
"OpenNewTab": "Open in New Tab",
25+
"HeaderName": "Name",
26+
}
27+
```
28+
* There are common texts that are present with `Common` prefix, try to check first if the exact label is already present there.
29+
* Every key follows PascalCase case style.
30+
* Every key that is used in an ARIA text should end with the suffix `ARIA`.
31+
* The order of keys inside of appearance should be order of in the order they appear in the source code
32+
33+
## Language Use
34+
35+
The Processing Foundation is specifically invested in expanding the communities of technology and the arts to include and support those who have not had equal access because of their race, gender, class, sexuality, and/or disability. We see software as a medium, something that connects two things. We view it as a means for thinking and making. We believe software, and the tools to learn it, should be accessible to everyone
36+
37+
With those principles in mind, we want to strongly suggest the use of non-gendered terms whenever possible. If it is not possible to avoid, use the most inclusive version.
38+
For instance, in Spanish translation we tackled that problem with a particular rule of thumb:
39+
Avoid male-gendered words, use instead the letter ‘e’ , we used the ‘e’ approach vs other approaches like ‘x’ or ‘@’ because you also need to think about how screen readers would read the text aloud.
40+
41+
## Background
42+
43+
Did you want to know the context?
44+
* The original idea for Alpha Editor in Spanish was addressed in [this issue](https://github.com/processing/p5.js-web-editor/issues/595)
45+
* The discussion regarding which library to use was addressed in [Library](https://github.com/processing/p5.js-web-editor/issues/1447)
46+
* [UI Design](https://github.com/processing/p5.js-web-editor/issues/1434)
47+
* [Language Use](https://github.com/processing/p5.js-web-editor/issues/1509)
48+
49+
50+
51+
Thanks!
52+
53+
P5.js Web Editor Community
54+

translations/locales/en-US/translations.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"PlayOnlyVisualSketchARIA": "Play only visual sketch",
100100
"StopSketchARIA": "Stop sketch",
101101
"EditSketchARIA": "Edit sketch name",
102-
"NewSketchNameARIA": "New sketch name"
102+
"NewSketchNameARIA": "New sketch name",
103+
"By": " by "
103104
},
104105
"Console": {
105106
"Title": "Console",
@@ -407,6 +408,7 @@
407408
"NumSketches_plural": "{{count}} sketches",
408409
"By":"Collection by ",
409410
"NoSketches": "No sketches in collection",
411+
"TableSummary": "table containing all collections",
410412
"HeaderName": "Name",
411413
"HeaderCreatedAt": "Date Added",
412414
"HeaderUser": "Owner",
@@ -445,6 +447,7 @@
445447
"Title": "p5.js Web Editor | My collections",
446448
"AnothersTitle": "p5.js Web Editor | {{anotheruser}}'s collections",
447449
"NoCollections": "No collections.",
450+
"TableSummary": "table containing all collections",
448451
"HeaderName": "Name",
449452
"HeaderCreatedAt": "Date Created",
450453
"HeaderCreatedAt_mobile": "Created",
@@ -487,6 +490,7 @@
487490
"ButtonLabelAscendingARIA": "Sort by {{displayName}} ascending.",
488491
"ButtonLabelDescendingARIA": "Sort by {{displayName}} descending.",
489492
"AddToCollectionOverlayTitle": "Add to collection",
493+
"TableSummary": "table containing all saved projects",
490494
"HeaderName": "Sketch",
491495
"HeaderCreatedAt": "Date Created",
492496
"HeaderCreatedAt_mobile": "Created",

translations/locales/es-419/translations.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
"PlayOnlyVisualSketchARIA": "Ejecutar bosquejo visual",
100100
"StopSketchARIA": "Detener bosquejo",
101101
"EditSketchARIA": "Editar nombre de bosquejo",
102-
"NewSketchNameARIA": "Nuevo nombre de bosquejo"
102+
"NewSketchNameARIA": "Nuevo nombre de bosquejo",
103+
"By": " de "
103104
},
104105
"Console": {
105106
"Title": "Consola",
@@ -407,6 +408,7 @@
407408
"NumSketches_plural": "{{count}} bosquejos",
408409
"By":"Colección por ",
409410
"NoSketches": "No hay bosquejos en la colección",
411+
"TableSummary": "tabla que contiene todas las colecciones",
410412
"HeaderName": "Nombre",
411413
"HeaderCreatedAt": "Fecha de agregación",
412414
"HeaderUser": "Propietario",
@@ -445,6 +447,7 @@
445447
"Title": "p5.js Web Editor | Mis colecciones",
446448
"AnothersTitle": "Editor Web p5.js | Colecciones de {{anotheruser}}",
447449
"NoCollections": "No hay colecciones.",
450+
"TableSummary": "la tabla contiene todas las colecciones",
448451
"HeaderName": "Nombre",
449452
"HeaderCreatedAt": "Fecha Creación",
450453
"HeaderCreatedAt_mobile": "Creación",
@@ -487,6 +490,7 @@
487490
"ButtonLabelAscendingARIA": "Ordenar por {{displayName}} ascendente.",
488491
"ButtonLabelDescendingARIA": "Ordenar por {{displayName}} descendente.",
489492
"AddToCollectionOverlayTitle": "Agregar a colección",
493+
"TableSummary": "la tabla contiene todos los proyectos guardados",
490494
"HeaderName": "Bosquejo",
491495
"HeaderCreatedAt": "Fecha Creación",
492496
"HeaderCreatedAt_mobile": "Creación",

0 commit comments

Comments
 (0)