Skip to main content
A newer version of this page is available.

Localization

  • 4 minutes to read

Localizing a scaffolding application is done in two steps.

Localization strings used by views

Scaffolding automatically generates two main .resx files to the Localization folder.

The first resource file is named based on the DbContext and contains strings retrieved from the data source.

The second resource file is named ViewResources. It contains strings used by generated views (for example, names of ribbon commands). The view resource in English, German, Russian, Spanish and Japanese localizations are ready to use.

Your can change localization files as you need and add new files.

sc-localization-05

Localization strings used by DevExpress libraries

Strings used by our controls and the base view models located in the DevExpress.Mvvm.ViewModel library (for example, error messages) are localized via the DevExpress Localization Mechanism. You can localize specific strings by using satellite resource assemblies, or via custom localizer objects.

Localization strings used in the DevExpress.Mvvm.ViewModel library are shown below.

ScaffoldingStringId Default value (en-US culture) Description
Confirmation_Delete “Do you want to delete this {0}?” The content of the confirmation message box that is invoked when the end-user attempts to delete a record.
Confirmation_Save “Do you want to save changes?” The content of the confirmation message box that is invoked when the end-user attempts to close a record editing form that has unsaved changes.
Confirmation_Reset “Click OK to reload the entity and lose unsaved changes. Click Cancel to continue editing data.” The content of the confirmation message box that is invoked when the end-user attempts to reset changes made to a record.
Confirmation_ResetLayout “Are you sure you want to reset layout? Reopen this view for the new layout to take effect.” The content of the confirmation message box that is invoked when the end-user attempts to reset the layout.
Confirmation_Caption “Confirmation” The header caption of the confirmation message box.
Confirmation_SaveParent “You need to save the parent {0} entity before adding a new record. Do you want to save it now?” The content of the confirmation message box that is invoked when the end-user attempts to add a new record to a parent record that has unsaved changes.
Warning_Caption “Warning” The header caption of the warning message box.
Warning_SomeFieldsContainInvalidData “Some fields contain invalid data. Click OK to close the page and lose unsaved changes. Press Cancel to continue editing data.” The content of the warning message box that is invoked when the end-user attempts to save changes made to a record while some fields contain invalid data.
Exception_UpdateErrorCaption “Update Error” The header caption of the exception message box that is invoked when loading data fails.
Exception_ValidationErrorCaption “Validation Error” The header caption of the exception message box that is invoked when the end-user attempts to save changes made to a record while some fields contain data that does not pass validation.
Exception_DataServiceRequestErrorCaption “DataService Request Error” The header caption of the exception message box that is invoked when an error occurs while processing a WCF Data Service request.
Entity_Changed “ *” This string is added to the header caption of a record editing form that has unsaved changes.
Entity_New “ (New)” This string is added to the header caption of a new record editing form.
Entity_Deleted “ (Deleted)” This string is added to the header caption of a deleted record form.
AddRemoveDetailEntities_SelectObjects “Select objects to add” The header caption of the dialog window used to add detail entities to an entity.

To localize scaffolding-specific strings via custom localizers, create a descendant of the DevExpress.Mvvm.Localization.ScaffoldingLocalizer class and override its PopulateStringTable method that adds strings for specified resource identifiers. To use this localizer, assign an instance of this class to the static Active property of the localizer class you derived from. See the example below.

ScaffoldingLocalizer.Active = new CustomScaffoldingLocalizer();
public class CustomScaffoldingLocalizer : ScaffoldingLocalizer {
    protected override void PopulateStringTable() {
        base.PopulateStringTable();
        AddString(ScaffoldingStringId.Confirmation_Delete, "Delete this {0}?");
        AddString(ScaffoldingStringId.Confirmation_Save, "Save changes?");
        AddString(ScaffoldingStringId.Confirmation_Caption, "Confirm Action");
    }
}