processing / processing/p5.js-web-editor
Web Editor - FES i18next integration
@almchung is already working on this.
Since Oct 14, 2021.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 1.7k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 8
Description
Nature of issue?
- Existing feature enhancement
Feature enhancement details:
This issue proposes an integration plan between the web editor and the Friendly Error System (FES).
The current web editor successfully displays FES messages in the default language. It would be even more helpful if the language of FES automatically matches with the detected or selected language in the web editor!
To integrate FES with the web editor, I’m thinking of following these steps:
-
p5js: Expose the language switching function
This mainly means to extendsetTranslatorLanguage()from our i18n module [LINK].p5._setTranslatorLanguage()can be a way to do this [LINK]. (Not sure whether this is the best place for it.) -
Web editor: Identify where the language option needs to be updated
(a) We’ll need to add the language option to where the sketch (in iframe) begins to run, such as thestartSketch()payload inmodules/IDE/actions/ide.js. Here we'll pass the locale detected by the Web Editor app.
(b) The Web Editor react app’slanguagestate is updated when language selection event happens (e.g. the dropdown menu UI), as seen incomponents/Nav.jsx/handleLangSelection(). I’m not sure whether we'll need to reload the sketch iframe/update language here.
(c) I wonder if I’m missing any other cases? -
Web editor: Handle messages with the language option
We’ll need to editmodules/Preview/previewIndex.jsxto handle the posted request and relay the language option toEmbedFrame. -
Web editor: Change language within the Sketch iFrame
WhenEmbedFramefinally receives the language option, I have a hacky plan to add a scriptp5._setTranslatorLanguage ({{langugage code}});to the iframe HTML. Maybe we can dynamically generatedefaultHTMLbased on the language option? If you know a more elegant way, I'd love to learn it!
@catarak and @outofambit, please feel free to comment if you have feedback on any of these steps.
Thank you! :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.