Skip to content

Commit 5527ebd

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into fix/installation-guide-update
2 parents 379628f + 2ae2649 commit 5527ebd

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

developer_docs/translations.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,47 @@ In order to simplify the translations process the following rules of thumb were
1010
## Technical Part
1111

1212
* 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)
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#L8)
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#L611)
1515
* Need to add `TRANSLATIONS_ENABLED=true` to `.env` to activate dropdown for the languages.
1616

17+
#### Nav.js
18+
Need to add the following code to add a new language as a dropdown menu.
19+
```js
20+
<li className="nav__dropdown-item">
21+
<button
22+
onFocus={this.handleFocusForLang}
23+
onBlur={this.handleBlur}
24+
value="newLanguageValue"
25+
onClick={e => this.handleLangSelection(e)}
26+
>
27+
new language name in the new language ex: 日本語 (Japanese)
28+
</button>
29+
</li>
30+
```
31+
32+
#### i18n.js
33+
In terms of `i18n.js`, you will need to update 2 things. One is to import a new language from `date-fns/locale`. The other is to add a new language to `languageMap`.
34+
35+
```js
36+
import { enUS, es, ja, newLanguage } from 'date-fns/locale';
37+
const availableLanguages = ['en-US', 'es-419', 'ja', 'newLanguage'];
38+
```
39+
40+
```js
41+
export function languageKeyToDateLocale(lang) {
42+
const languageMap = {
43+
'en-US': enUS,
44+
'es-419': es,
45+
'ja': ja
46+
'newLanguage': newLanguage
47+
};
48+
return languageMap[lang];
49+
}
50+
```
51+
52+
53+
1754
## Translations
1855

1956
* Every component should introduce its own subset of keys inside a dictionary named after the component.

server/controllers/project.controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ export function projectForUserExists(username, projectId, callback) {
148148
return;
149149
}
150150
Project.findOne({ user: user._id, $or: [{ _id: projectId }, { slug: projectId }] }, (innerErr, project) => {
151-
if (project) {
152-
callback(true);
151+
if (!project) {
152+
callback(false);
153+
return;
153154
}
155+
callback(true);
154156
});
155157
});
156158
}

0 commit comments

Comments
 (0)