-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UI] Make keyword toggle also switcher language of the editor #4828
Conversation
Hi @jpelay! I think this all works as expected (basically I just merged 2 functions) but I would like a sanity check on my typescript :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jpelay!
I think this all works as expected (basically I just merged 2 functions) but I would like a sanity check on my typescript :)
So cool to have you working on the front-end too 😄 The typescript code looks fine! I have a comment not related to the front-end but to the translation process:
If the program has a syntax error, it doesn't get translated, and no message is shown. Perhaps we can translated the commands that are properly written or show a message? What do you think?
for more information, see https://pre-commit.ci
Thanks! I actually really likes writing a bit of typescript, I maybe want to do more of that going forward!
That is a great catch! I saw the front-end message appear so I assumed it would work always but it turned out it only worked for ParseErrors but not for error productions that are caught on the way! Turned out... (plot twist!) there was an old comment from me documenting this issue: Line 95 in a8e7bf0
Fixed that now! |
A few issues remain (note to self):
|
for more information, see https://pre-commit.ci
…nto language-switcher
This reverts commit e08375d.
for more information, see https://pre-commit.ci
This reverts commit d15d5f7.
…nto language-switcher
for more information, see https://pre-commit.ci
This reverts commit 9516f7f.
…nto language-switcher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything works great now!!!
Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork). |
(This is a redo of #4867 which contained some commits now already on main) Since #4828 translation features are more prominently visible, so I figured we need to do a bit better. This actually changes some conceptual assumptions, so let's document here: * Programs that have a ParseError or contain Placeholders, or have indentation issues, still cannot be translated (since they can't be parsed and then we don't have a tree to work wtih) * All other errors however create a parsetree with error nodes, and thus... can just be translated keeping the error nodes, so that is what we now do! **How to test** Try a program with an error production, f.e. in German, level 7: `repeat 3 times 'Hedy macht Spaß!'` Main shows an error: <img width="724" alt="image" src="https://github.com/hedyorg/hedy/assets/1003685/2ec4d071-9c1e-4e10-9a9b-606024e42e37"> This PR translates the code: <img width="693" alt="image" src="https://github.com/hedyorg/hedy/assets/1003685/4d3c4410-900c-4b98-99f2-502672e42420">
Fixes #4420
Some background
I want to describe a bit of background here because this is such a lovely example of a set of very reasonable decisions leading to bad design!
When we introduced the keyword languages, we added a switcher on the top of the screen, to switch all code examples in the adventures. So far so good. But we also switched start codes in the editor and translated them (since they have {}, the translation does not mean parsing but means grabbing from the yaml file and replacing the keywords). This happens when you have not written code yet. If you do, it does not load the startcode and then it does not translate.
But... Since we seems to translate code in the editor... people thought it could also translate their own code. It actually took me a long time to figure out why people (like @Mark-Giesen) thought that that is what the button would do!
This PR makes the one button translate in the editor too.
Limitations
The error handling in the translation code is currently quite limited. I tried to expand it in e08375d but it will involve extensive refactoring to do it nicely, so I prefer to do that separately.
I was also planning to Rename the top switcher so that it does not show the translation emoji, but the current keyword language (so: en or nl), but this leads to some design issues (#4828 (comment)) that I also want to address separately.
Changes
How to test
Set Hedy to any non-En language and write code in that language (f.e. slaap 20 in Dutch, level 4). Use the toggle and observe the keywords being translated.
Create a broken program with a parse error and see the error message appear below.