How to Implement Localization in .NET MAUI SfAIAssistView?
8 Jul 20262 minutes to read
Localization is the process of translating the application resources into different languages for specific cultures. The SfAIAssistView can be localized by adding a resource file.
Setting the CurrentUICulture in the Application
Application culture can be changed by setting the CurrentUICulture in the App.xaml.cs file.
using Syncfusion.Maui.AIAssistView;
using System.Globalization;
using System.Resources;
namespace MauiAssistView
{
public partial class App : Application
{
public App()
{
InitializeComponent();
CultureInfo.CurrentUICulture = new CultureInfo("es");
SfAIAssistViewResources.ResourceManager = new ResourceManager("MauiAssistView.Resources.SfAIAssistView", Application.Current!.GetType().Assembly);
MainPage = new MainPage();
}
}
}NOTE
The required
resxfiles (a defaultSfAIAssistView.resxand one or more culture-specificSfAIAssistView.<culture code>.resxfiles) must be added withBuild Actionset toEmbeddedResourceto theResourcesfolder. The file name of culture-specific resx files must include the culture code (for example,SfAIAssistView.es.resxfor Spanish).
Localize application level
To localize the AI AssistView based on the CurrentUICulture using resource files, follow these steps.
-
Create a new folder named
Resourcesin the application. -
Right-click on the
Resourcesfolder, selectAdd, then click onNewItem. -
In the Add New Item wizard, select the Resource File option and name the filename as
SfAIAssistView.<culture code>.resx. For example, give the name asSfAIAssistView.es.resxfor Spanish culture. -
The culture code identifies the language (and optionally the country/region).

- Now, select the
Addoption to add the resource file in the Resources folder.

- Add the Name/Value pair in the Resource Designer of
SfAIAssistView.es.resxfile and change its corresponding value to the text for the target culture.
