The LocalizeEntities policy set

Abstract

How to use the LocalizeEntityPolicy policy to make the properties of an Entity or an Entity Component localizable.

When a Commerce entity property is localizable, the Business Tools GUI lets business users add translated versions of the property string values in the supported languages. The PlugIn.LocalizeEntities.PolicySet-1.0.0.json file contains instances of the LocalizeEntityPolicy and LocalizeEntityComponentPolicy policies that are responsible for making Commerce entity properties localizable.

The PlugIn.LocalizeEntities.PolicySet-1.0.0.json file, located under wwwroot\<CommerceEngineService>\wwwroot\data\Environments, contains two entity policy types:

  • The Sitecore.Commerce.Core.LocalizeEntityPolicy policy lists the properties of entity views that are exposed for localization.

  • The Sitecore.Commerce.Core.LocalizeEntityComponentPolicy policy lists the properties of child entity views that are exposed for localization. This policy is embedded within the LocalizeEntityPolicy policy.

The following is a sample from the PlugIn.LocalizeEntities.PolicySet-1.0.0.json file that makes some of the sellable item entity properties and child views (component) properties localizable by default. The sample illustrates the hierarchical relationship of the LocalizeEntityPolicy and the LocalizeEntityComponentPolicy policies, where the sellable item entity LocalizeEntityPolicy has a ComponentsPolicies attribute that contains multiple imbedded instances of the LocalizeEntityComponentPolicy policy, each with their own list of child view properties to localize.

{
   "$type": "Sitecore.Commerce.Core.LocalizeEntityPolicy, Sitecore.Commerce.Core",
   "Type": "Sitecore.Commerce.Plugin.Catalog.SellableItem",
      "Properties": [
         "DisplayName", 
         "Description",   
         "Brand"   
      ],
      "ActionView": "Details",
      "ComponentsPolicies": [
          {
            "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
            "Path": "DisplayPropertiesComponent",
            "Properties": [
              "Color",
              "Size",
              "Style",
              "DisambiguatingDescription"
            ],
            "ActionView": "DisplayProperties",
            "IsItemComponent": false
          },
          {
            "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
            "Path": "ItemVariationsComponent.ItemVariationComponent",
            "Properties": [
              "DisplayName",
              "Description"
           ],
            "ActionView": "Details",
            "IsItemComponent": true
          },
          {
            "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
            "Path": "ItemVariationsComponent.ItemVariationComponent.DisplayPropertiesComponent",
            "Properties": [
              "Color",
              "Size",
              "Style",
              "DisambiguatingDescription"
            ],
            "ActionView": "DisplayProperties",
            "IsItemComponent": true

Properties of the LocalizeEntityPolicy policy

Properties of the LocalizeEntityPolicy policy are:

Properties

Description

"Type"

The Commerce entity type that defines properties.

"Properties"

A list of the entity properties to make available for localization.

"ActionView"

The entity view where the properties are used.

"ComponentsPolicies"

Introduces one or multiple instances of the LocalizeEntityComponentPolicy policy to localize properties of child views, including properties of sellable item variants.

Properties of the LocalizeEntityComponentPolicy policy

Properties of the LocalizeEntityComponentPolicy policy are:

Properties

Description

"Path"

The path to the component with the display properties.

"Properties"

A list of the display properties to make available for localization.

"ActionView"

The view where the properties are used.

"IsItemComponent"

Used as a filter to determine whether a LocalizableComponentPolicy applies to a view representing a given level of the entity.

When set to true, the component properties are localizable at the component level (for example, at the sellable item variant level).

When set to false, the component properties are localizable at the entity level (for example at the sellable item level). Sellable item variants inherit the localized property values.