Skip to content
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

Codemirror not highlighting code in locales other than English #102

Open
Danita opened this issue Mar 5, 2017 · 4 comments
Open

Codemirror not highlighting code in locales other than English #102

Danita opened this issue Mar 5, 2017 · 4 comments

Comments

@Danita
Copy link

Danita commented Mar 5, 2017

Hi, I forked this wonderful project in order to add the Spanish translation, and today I stumbled on this. Please excuse any inaccuracies because I'm not completely familiar with the codebase yet.

As I understand the problem arises from the CM logo lexer cm/logo.js having the English keywords hardcoded. Possible solutions that come to my mind:

  • Add a new lexer for each language code. Cons: too much shared code.
  • Attempt to monkeypatch the CodeMirror mode indent() and token() after reading the l10n file to support custom regexes.
  • Best, I think: programmatically generate the lexer according to the selected language and lazy loading it.

Thoughts?

@inexorabletash
Copy link
Owner

We really only need the keywords TRUE, FALSE, ELSE, TO and END, correct? (As an aside, the interpreter doesn't treat TRUE, FALSE and TO as keywords; perhaps it should.)

Another option that comes to mind is to have the mode's lexer have hooks that index.js can interact with, much like the interpreter itself. We could assign a keyword map to the global (window) or another object and the mode's lexer could use that rather than hardcoded regular expressions. That might be simpler.

Otherwise, I agree that programmatically generating the lexer might be easiest. I'd definitely be willing to review patches here. Thank you very much for reporting this and investigating possible options!

@Danita
Copy link
Author

Danita commented Mar 7, 2017

You're welcome Joshua, I liked your implementation of Logo very much and I'll be collaborating on a time-permitting basis 😄

I agree the hooks approach might be simpler to implement. I'll try this once I finish the Spanish translation.

@Svish
Copy link
Contributor

Svish commented May 1, 2017

Shouldn't the keywords (like is usually the case with programming languages) always be in English? Regardless of the language used "around" it?

@inexorabletash
Copy link
Owner

Since Logo is aimed at introductory programming (and kids) it is often localized, even down to the level of keywords. Particularly when the procedure library is localized, the remaining keywords — and there's only a few, listed above — really stand out.

Standardization and portability of the language was never a big concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants