How can I render the CodeEffects Rule Editor in a different language (Let's say Arabic).
I am using a custom class as the source object for the rule model and passing that in the viewbag to the view, there i am rendering the rule editor using that. I have not explictely called any source xml or help xml doc. the rule editor is picking the default english version.
@{
Html.CodeEffects().RuleEditor()
.Id("ruleEditor")
.SaveAction("SaveGroup", "Campaign")
.DeleteAction("DeleteGroup", "Campaign")
.LoadAction("LoadGroup", "Campaign")
.Mode(RuleType.Evaluation)
.ToolBarRules(ViewBag.ToolBarRules)
.Rule(ViewBag.Rule)
.Render();
}
So far on CodeEffects official documentation I have come accross this Help XML and Multilingual Support in Code Effects but I couldn't understand it properly
How can I load a custom help xml and source xml file from the cshtml page using razor syntax
Any help would be appreciated.
In general, you simply create your own version of the Help XML in your language and pass it to the editor on the server using the editor's HelpXmlFile property during the editor initialization.
You also need to have your own version of the Source XML with all display names translated in your language if you want your fields, in-rule methods and rule actions to be displayed in your language on the client. You can pass that source xml to the editor using the its SourceXmlFile property.
Call editor.GetHelpXml() method to get the default version of the Help XML to be translated; call editor.GetSourceXML() to get the Source XML of your source object to be translated (pass your source class to your editor first before calling that method, of course.)
EDIT:
As I said earlier, you need to use your own custom version of the Help XML which sets language-specific labels of all static UI elements such as buttons, Help String, etc. To do that, create a default instance of the RuleEditor class and call its GetHelpXml() method. That gives youa string of the default English xml document. Translate all its node values to your language, save it and pass that new xml to the editor using one of the overloads of its Help() extension method. Details can be found here.
I assume that you also need to have all properties, in-rule methods and rule actions displayed in your language. You have two options here:
If your project only uses one language, then simply use the FieldAttribute, MethodAttribute and/or ActionAttribute to set their DisplayName properties to values in your language. Details are here, here, and here.
If your project uses multiple languages then create an instance of the RuleEditor class, set its SourceType property to the type of your source class and call its GetSourceXml() method whoch returns a string of the XML doc that represents your source class. Create a copy of that doc for each of the language your project uses, translate all value of the "displayName" attributes in correspondent language, save those files and pass the desired one to the RuleModel.Create() method when you init the editor on the server. Details are here.