Locale options - Richasy/Controls-MarkdownEditBox GitHub Wiki
EditorLocaleOptions
is used for localization, The monaco-editor is a bit difficult to localize and cannot be changed at runtime (maybe somewhere has a good solution, but I didn't find it). So the text configuration defined here is specific to the context menu of the editor.
Create
By default, the control provides two localization configurations, Simplified Chinese and English. If you want to define a new language, you can refer to en-US.json to create a language definition file and import it as follows:
var myLocaleFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/zh-TW.json"));
string myLocaleJson = await FileIO.ReadTextAsync(myLocaleFile);
var localeOptions = EditorLocaleOptions.CreateOptions("zh-TW", myLocaleJson);
If you happen to need simplified Chinese or English localization configuration, you can directly call
EditorLocaleOptions.GetDefaultZhOptionsAsync()
or EditorLocaleOptions.GetDefaultEnOptionsAsync()
to get the corresponding configuration.
Call MyEditor.CurrentLocaleOptions
to get current options.
Update
MarkdownEditBox
supports dynamic modification of localized configuration.
In short, it is to overwrite the old configuration with the new configuration, like this:
MyEditor.UpdateLocaleOptions(newLocaleOptions);
If you only modify the existing localization configuration (such as modifying the value of an item), it will not be reflected on the UI, you must call UpdateLocaleOptions
to re-assign the value.