Localization in Blazor DataForm component
12 Jan 20242 minutes to read
DataForm component can be localized to any particular culture. Refer to Blazor Localization topic to localize Syncfusion Blazor components.
Configuring localization for label text and error messages
Follow the below steps to configure localization for label text and error messages in Blazor DataForm component.
1.After integrating the localization files in your application as mentioned in the Blazor Localization section ,Open the required culture file in the Visual Studio.
2.In the opened file click on Add Resource
button and include the suitable key with the corresponding localized text as like below.
3.Then, include the ResourceType which we have formed under Resources
folder and key for the localized text within the Display attribute of the corresponding property in the model class.Similarly you can localize the error messages in the DataForm component by including the ErrorMessageResourceType and ErrorMessageResourceName properties within the Required attribute of the corresponding property in the model class as mentioned in the below code snippet.
@using Syncfusion.Blazor.DataForm
@using System.ComponentModel.DataAnnotations
@using BlazorApp1.Resources
@using Syncfusion.Blazor.Buttons
<SfDataForm Width="50%"
Model="@RegistrationDetailsModel">
<FormValidator>
<DataAnnotationsValidator></DataAnnotationsValidator>
</FormValidator>
<FormItems>
<FormAutoGenerateItems></FormAutoGenerateItems>
</FormItems>
</SfDataForm>
@code {
private RegistrationDetails RegistrationDetailsModel = new RegistrationDetails();
}
@using Syncfusion.Blazor.DataForm
@using System.ComponentModel.DataAnnotations
@using BlazorApp1.Resources
@using Syncfusion.Blazor.Buttons
<SfDataForm Width="50%"
Model="@RegistrationDetailsModel">
<FormValidator>
<DataAnnotationsValidator></DataAnnotationsValidator>
</FormValidator>
<FormItems>
<FormAutoGenerateItems></FormAutoGenerateItems>
</FormItems>
</SfDataForm>
@code {
private RegistrationDetails RegistrationDetailsModel = new RegistrationDetails();
}
4.Finally, run the application to view the localized DataForm component.