Localization in Xamarin Picker (SfPicker)
31 May 20212 minutes to read
You can localize
Picker in all the platforms by adding a.resx file in a.NET Standard project alone. The following steps describe how to localize SfPicker in a project and you can download the complete sample from this
NOTE: Here, the resources have been already created for some cultures and shared them on
Syncfusion GitHubfor your convenience.
Add a new folder in the .NET Standard project named Resources.
Add resource files for the languages you wish to support, and set their Build Action to EmbeddedResource. The name of the resource file should be $name of the Syncfusion component$+$language code$+.resx. For example, if you add a resource file for the French culture, add the Syncfusion.SfPicker.XForms.fr-FR.resx file to Resources folder as illustrated in the following screenshot.
- Provide the French values for each key in the respective .resx files. Here, “Cancel” and “Ok” are the keys, and “Annuler” and “D’accord” are their respective French values.
<data name="Cancel" xml:space="preserve"> <value>Annuler</value> </data> <data name="Ok" xml:space="preserve"> <value>D'accord</value> </data>
- Set the resource manager to
PickerResourceManager.Manageras demonstrated in the following code to get the resource manager from the users. For more details, refer
PickerResourceManager.Manager = new ResourceManager("PickerLocalization.Resources.Syncfusion.SfPicker.XForms", Application.Current.GetType().Assembly);
Localize at application level
You can also localize the text at application-level regardless of the language selected on the device. The following platform-specific codes are needed to localize the text at application-level.
//For Android and iOS, Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); //For UWP, CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");
You can refer to our Xamarin Picker feature tour page for its groundbreaking feature representations. You can also explore our Xamarin.Forms Picker example to knows the functionalities of each feature.