Localization in .NET MAUI Popup (SfPopup)

15 Jul 20262 minutes to read

Localization is the process of translating the application resources into different languages for specific cultures. The SfPopup can be localized by adding a resource file.

Setting CurrentUICulture to the application

Application culture can be changed by setting the CurrentUICulture in the App constructor of the App.xaml.cs file.

using Syncfusion.Maui.Popup;
using Syncfusion.Maui.Popup.Localization;
using System.Globalization;
using System.Resources;

public partial class App : Application
{
   public App()
   {
      InitializeComponent();
      CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");
      //// ResXPath => Full path of the resx file; For example : //SfPopupResources.ResourceManager = new ResourceManager
      // ("MauiPopupDemo.Resources.SfPopup", Application.Current.GetType().Assembly);

      SfPopupResources.ResourceManager = new ResourceManager(ResXPath, Application.Current.GetType().Assembly);
      MainPage = new MainPage();
   }
}

NOTE

Add the required resx files to the Resources folder, with the Build Action set to EmbeddedResource. The file name must contain the culture code.

Localize at the application level

To localize the Popup based on the CurrentUICulture using the resource files, follow these steps.

  1. In the project’s existing Resources folder, right-click and select Add, then NewItem.

  2. In the Add New Item wizard, select the Resource File option and name the filename as SfPopup.<culture name>.resx. For example, give the name as SfPopup.fr-FR.resx for French culture.

  3. The culture name indicates the name of the language and country.

Syncfusion .NET MAUI Popup shows the name of resource file to be added

  1. Now, select the Add option to add the resource file in the Resources folder.

Syncfusion .NET MAUI Popup shows the added resource file for french language

  1. Add the Name or Value pair in the Resource Designer of SfPopup.fr-FR.resx file and change its value to the localized text for the target culture.

Syncfusion .NET MAUI Popup shows the added resource file name value pair in the resource designer