Managed Forms, Entity Forms and Web Forms leverage the CrmEntityFormView control to render forms and support multiple languages by using Microsoft Dynamics CRM label translations to display the localized strings. 

1. Install Microsoft Dynamics CRM Language Packs

Microsoft Dynamics CRM Language Packs must be installed for each language that you wish to provide label translations. For complete details please see Language Pack Installation Instructions

2. Label Translations

To specify label translations for your customizations, please see Customize Labels to Support Multiple Languages

Do not translate the names of forms that will be used to render in the portal as these are selected by name and if localized, the names will not match and an error will be thrown in the portal.

3. Localized User Accounts

In order to retrieve the form's localized labels, the user account making the connection to CRM must have the appropriate language set. You will need to create a CRM System User record for each language and login to CRM with the account and set the language in the options.  

4. Create Multiple Region Websites

For each language that you would like to support, you will create a subscribing website to the master base language website. For further details regarding multi region websites, refer to the following article.

Use the WebsiteCopy utility to create subscribing websites. For complete details regarding the usage of the WebsiteCopy utility please refer to the following article.

The Adxstudio Portals installation contains a sample portal titled 'Company Portal' that contains a multilingual implementation with a French subscribing website. If you would like to review this sample, the project files and website backup XML files can be found in the product's install directory (C:\Program Files (x86)\Adxstudio\XrmPortals\<version>\Samples\)

Specify Language Code Site Setting:

The following Site Setting associated with a website determines the Language Code assigned to the form control to retrieve the appropriate translated labels.

For your base language you can ignore assigning a value for this setting and the context will load the default one named "Xrm" in your web.config. Otherwise you will need to modify the web.config and add entry for your base language code. See Portal Configuration below.
  • Navigate to Portals -> Site Settings

Repeat the following for each region's website

  • Click New
  • Enter the Name as "Language Code"
  • Select the Website
  • Specify the Value, Enter the integer value of the language code (Locale ID) for the website's associated region. Microsoft Locale ID Values

5. Portal configuration

The following modification must be made to any new form templates in the portal to support language localization of CRM form components.

Modify the Web Portal's Configuration File:

Edit the web.config file found in the root directory of the portal.

A connection string must be specified with a particular user with the appropriate language option set for each language. Entry with the name "Xrm" represents the default base language. For each additional entry, the name should be the language code associated with that language.

<connectionStrings>
   <add name="Xrm" connectionString="Url=http://crm2011/contoso; Domain=contoso; Username=EnglishUser; Password=******"/>
   <add name="1036" connectionString="Url=http://crm2011/contoso; Domain=contoso; Username=FrenchUser; Password=******"/>
</connectionStrings>

Contexts and services must be specified for each language. Entry with the name "Xrm" represents the default base language. For each additional entry, the name should be the language code associated with that language.

<microsoft.xrm.client mutexProviderType="Adxstudio.Xrm.Threading.MonitorLockProvider, Adxstudio.Xrm">
   <contexts default="Xrm">
      <add name="Xrm" type="Microsoft.Xrm.Client.CrmOrganizationServiceContext, Microsoft.Xrm.Client" connectionStringName="Xrm" serviceName="Xrm" />
      <add name="1036" type="Microsoft.Xrm.Client.CrmOrganizationServiceContext, Microsoft.Xrm.Client" connectionStringName="1036" serviceName="1036" />
   </contexts>
   <services>
      <add name="Xrm" type="Adxstudio.Xrm.Services.CrmOnlineOrganizationService, Adxstudio.Xrm" serviceCacheName="Xrm" />
      <add name="1036" type="Adxstudio.Xrm.Services.CrmOnlineOrganizationService, Adxstudio.Xrm" serviceCacheName="1036" />
   </services>
   <serviceCache default="Xrm">
      <add name="Xrm" type="Adxstudio.Xrm.Services.ContentMapOrganizationServiceCache, Adxstudio.Xrm" objectCacheName="Xrm" />
      <add name="1036" type="Adxstudio.Xrm.Services.ContentMapOrganizationServiceCache, Adxstudio.Xrm" objectCacheName="1036" />
   </serviceCache>
   <objectCache default="Xrm">
      <add name="Xrm" type="Adxstudio.Xrm.Caching.OutputObjectCache, Adxstudio.Xrm"/>
      <add name="1036" type="Adxstudio.Xrm.Caching.OutputObjectCache, Adxstudio.Xrm"/>
   </objectCache>
</microsoft.xrm.client>

A portal configuration must be specified for the master website and each subscribing website.  Entry with the name "Xrm" represents the default base language. For each additional entry, the name should be the language code associated with that language. The contextName property must be specified as the language code for the given language.

<microsoft.xrm.portal>
   <portals default="Xrm">
      <add name="Xrm" websiteName="Portal Name" type="Adxstudio.Xrm.PortalContext, Adxstudio.Xrm">
         <websiteSelector type="Adxstudio.Xrm.Cms.WebsiteSelectors.NameAndWebsitePathWebsiteSelector, Adxstudio.Xrm"/>
         <dependencyProvider type="Adxstudio.Xrm.Web.Configuration.DependencyProvider, Adxstudio.Xrm"/>
         <crmEntitySecurityProvider type="Adxstudio.Xrm.Cms.Security.CmsCrmEntitySecurityProvider, Adxstudio.Xrm"/>
      </add>
      <add name="1036" websiteName="Portal Name French" contextName="1036" type="Adxstudio.Xrm.PortalContext, Adxstudio.Xrm">
         <websiteSelector type="Adxstudio.Xrm.Cms.WebsiteSelectors.NameAndWebsitePathWebsiteSelector, Adxstudio.Xrm"/>
         <dependencyProvider type="Adxstudio.Xrm.Web.Configuration.DependencyProvider, Adxstudio.Xrm"/>
         <crmEntitySecurityProvider type="Adxstudio.Xrm.Cms.Security.CmsCrmEntitySecurityProvider, Adxstudio.Xrm"/>
      </add>
   </portals>
</microsoft.xrm.portal>

For Managed Forms (CrmEntityFormView):

Modify the .aspx Page Template containing the CrmEntityFormView control
  • Open the web portal's Visual Studio Project.
  • Open the .aspx file containing the CrmEntityFormView control.
  • Ensure the adx:CrmEntityFormView control declaration has the property ID="FormControl"
  • Open the code behind file .aspx.cs
  • Replace or Add the Page_Init method with the following
protected void Page_Init(object sender, EventArgs e)
{
   var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
   var context = new XrmServiceContext();
   var website = context.Adx_websiteSet.FirstOrDefault(w => w.Adx_websiteId == portalContext.Website.Id);
   if (website == null)
   {
      return;
   }
   var languageCodeSetting = context.GetSiteSettingValueByName(website, "Language Code");
   if (string.IsNullOrWhiteSpace(languageCodeSetting))
   {
      return;
   }
   int languageCode;
   if (!int.TryParse(languageCodeSetting, out languageCode))
   {
      return;
   }
   FormControl.LanguageCode = languageCode;
   FormControl.ContextName = languageCode.ToString(CultureInfo.InvariantCulture);
}

For Web Forms

Modify the WebForm.aspx Page Template or .aspx Page Template containing the WebForm control
  • Open the web portal's Visual Studio Project.
  • Open the WebForm.aspx file or the .aspx file containing the WebForm server control.
  • Ensure the adx:WebForm control declaration has the property ID="WebFormControl"
  • Open the code behind file WebForm.aspx.cs
  • Replace or Add the Page_Init method with the following
protected void Page_Init(object sender, EventArgs e)
{
   var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
   var context = new XrmServiceContext();
   var website = context.Adx_websiteSet.FirstOrDefault(w => w.Adx_websiteId == portalContext.Website.Id);
   if (website == null)
   {
      return;
   }
   var languageCodeSetting = context.GetSiteSettingValueByName(website, "Language Code");
   if (string.IsNullOrWhiteSpace(languageCodeSetting))
   {
      return;
   }
   int languageCode;
   if (!int.TryParse(languageCodeSetting, out languageCode))
   {
      return;
   }
   WebFormControl.LanguageCode = languageCode;
   WebFormControl.PortalName = languageCode.ToString(CultureInfo.InvariantCulture);
}

For Entity Forms

Modify the EntityForm.aspx Page Template or Template containing the EntityForm control
  • Open the web portal's Visual Studio Project.
  • Open the template file containing the EntityForm server control.
  • Ensure the adx:EntityForm control declaration has the property ID="EntityFormControl"
  • Open the code behind file .cs
  • Replace or Add the Page_Init method with the following
protected void Page_Init(object sender, EventArgs e)
{
   var portalContext = PortalCrmConfigurationManager.CreatePortalContext();
   var context = new XrmServiceContext();
   var website = context.Adx_websiteSet.FirstOrDefault(w => w.Adx_websiteId == portalContext.Website.Id);
   if (website == null)
   {
      return;
   }
   var languageCodeSetting = context.GetSiteSettingValueByName(website, "Language Code");
   if (string.IsNullOrWhiteSpace(languageCodeSetting))
   {
      return;
   }
   int languageCode;
   if (!int.TryParse(languageCodeSetting, out languageCode))
   {
      return;
   }
   EntityFormControl.LanguageCode = languageCode;
   EntityFormControl.PortalName = languageCode.ToString(CultureInfo.InvariantCulture);
}