Localization
v7
The user can set the application language. Starting from API V7, plugins whose logic depends on the terminal language can handle language changes.
How does it look in SyrveFront?
Changing the language is done through the settings screen:

The terminal language cannot be changed through the plugin.
How to find out the current language
The current application language can be determined using the method IOperationService.GetHostTerminalSettings():
var settings = PluginContext.Operations.GetHostTerminalSettings();
The method returns an object that implements the interface IHostTerminalSettings.
It contains two localization properties:
CultureInfo Culture- the language selected on the terminal.CultureInfo UICulture- added in API V7. Currently, the property contains the same value as theCultureproperty. Support for different cultures for data and user interface is planned for the future.
Plugin startup settings
Starting from API V7, during application startup, the plugin automatically retrieves localization settings from the terminal. Before the plugin code is called, the following properties are set:
CultureInfo.CurrentCultureCultureInfo.CurrentUICultureCultureInfo.DefaultThreadCurrentCultureCultureInfo.DefaultThreadCurrentUICulture
They receive the same values as on the terminal.
Currently, the CurrentUICulture property will have the same value as CurrentCulture, and DefaultThreadCurrentUICulture will have the same value as DefaultThreadCurrentCulture.
Tracking language changes by the plugin
The user can change the language of the SyrveFront application during its operation.
This will result in the culture properties described above being changed.
However, automatically changing the values of these properties for the plugin code is a risky operation.
For example, at the moment the terminal language is changed, the plugin may be performing an operation whose result depends on the culture.
Therefore, it was decided not to automatically set these properties for plugins in the case of language changes during operation.
In API V7, the event INotificationService.CurrentCultureChanged was added, allowing tracking of terminal language changes and setting the plugin culture at a convenient moment.
This event has 2 arguments:
CultureInfo culture- the new culture.CultureInfo uiCulture- the same asculture.
For example, if the plugin code allows for immediate application of new settings, the properties can be set right away:
PluginContext.Notifications.CurrentCultureChanged.Subscribe(x =>
{
CultureInfo.CurrentCulture = x.culture;
CultureInfo.CurrentUICulture = x.uiCulture; //Currently the same as x.culture
CultureInfo.DefaultThreadCurrentCulture = x.culture;
CultureInfo.DefaultThreadCurrentUICulture = x.uiCulture; //Currently the same as x.culture
});
Restoring old behavior
If the plugin should not change the culture when the terminal starts, you can write code in its constructor to revert the culture to its original state:
public MyPlugin()
{
//Set the culture from the operating system settings
CultureInfo.CurrentCulture = CultureInfo.InstalledUICulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InstalledUICulture;
CultureInfo.CurrentUICulture = CultureInfo.InstalledUICulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InstalledUICulture;
}