SetCustomString for JavaScript strings

SyntaxEditor Web Languages Add-on for WPF Forum

Posted 7 years ago by Bastian Mattes
Version: 16.1.0636
Platform: .NET 4.5
Environment: Windows 10 (64-bit)
Avatar

EDIT: This forum seems to have some problem, it removed half of my post. I was saying that setting custom strings for xml works, but not for javascript.

 

 

ActiproSoftware.Products.Text.Addons.JavaScript.SR.SetCustomString(ActiproSoftware.Products.Text.Addons.JavaScript.SRName.JavaScriptExpressionErrorAlias.ToString(), "Test");

It still says "Expression", and not "Test", in the JavaScript editor.

I'm calling the methods in the viewmodel of the view where I'm using the syntax editor.

[Modified 7 years ago]

Comments (3)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bastian,

Hmm, odd... we haven't had any other reports of issues with the forum and the code has been the same for years.  We'll keep an eye out for problems.

In regards to the Javascript question, I pasted that line in our sample app startup and when I loaded up some JS code with an expected expression, I saw "Test expected." properly as an error.  If you aren't seeing it, it could be that you are setting it after the grammar is already compiled up.  Make sure you set those kinds of string customization lines in app startup before any of our other classes are referenced.  Then it should work fine.


Actipro Software Support

Posted 7 years ago by Bastian Mattes
Avatar

Maybe it has something to do with clearing the custom strings. The view model where I set the custom strings is created and disposed each time I open and close the window with the syntax editor. In the constructor of the view model I set the custom strings and in the dispose method I clear the custom strings. Maybe it has some problems with that.

I moved the code that sets the custom strings outside of the view model so that it isn't called every time the editor opens and also removed the clearing of custom strings and now it seems to work. Maybe that info helps more.

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Bastian,

The first time the parser is used, it compiles the grammar and pulls whatever string resources are currently set into the compiled grammar.  Changing string resources after that will not alter any already-compiled parser grammars.  That's why we always suggest only changing string resources in app startup prior to any of our UI or components being referenced.


Actipro Software Support

The latest build of this product (v24.1.2) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.