Change the language of an existing editor
See original GitHub issueI am making a directive to help using Monaco Editor in AngularJS 1.X framework. One feature should be updating the language based on the option. But I cannot change the language.
It seems that the type of monacoeditor
in my code is ICommonCodeEditor
, I tried monacoeditor.updateOptions({ "language": newValues[key] })
, it did nothing. I tried monacoeditor.getModel().updateOptions({ "language": newValues[key] })
, it did nothing either. I tried also monacoeditor.setModelLanguage(monacoeditor.getModel(), newValues[key])
, it gave an error TypeError: monacoeditor.setModelLanguage
is not a function.
Note that it is not the problem of the directive, because it works well to change options like lineNumbers
.
Could anyone help?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Change the language Office uses in its menus and proofing ...
To configure the editing and proofing language: Within any Office application, select File > Options > Language. The dialog box where you can...
Read more >How to Change the Language in Microsoft Word
Open an existing or new document in Microsoft Word and select Tools > Language on the menu bar. Pick an editing language, ensure...
Read more >To change the language of your account (and Editor)
Click the user panel at the top right to open it. Hover over the language at the bottom. Select from the list of...
Read more >Change your language on the web - Computer - Google Support
Sign in to your Google Account. · On the left, click Personal info. · Under "General preferences for the web," click Language and...
Read more >How to Change the Proofing Language for Comments in ...
Because … Comments in Word Inherit Proofing Languages. When you use Word's Track Changes to edit someone else's document, the comment tool automatically ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@SoftTimur from you snippet, it seems you create the editor from string (if you create a model first then my previous comment answers your question IMO).
setModelLanguage
is a function we exposed in modulemonaco.editor
, it’s not a method of the editor object. So in your case, you can doHope this helps you out, if it still doesn’t solve it, I’ll reopen this issue. BTW, you may want to refer
monaco.d.ts
file for typings reference.monaco.editor.setModelLanguage
works as expected. Please make sure you are setting language names correctly.