Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

Globalization scenarios

This document outlines some common globalization scenarios for EPiServer CMS solutions, and provides an overview of language-specific settings and properties for CMS content.

Scenario 1 – global domain with multiple languages

You want all your visitors to go to the official “site.com” address, but need to display different content depending on their language selection.

  1. Set a default language that most of your visitors will understand, normally English for a global site. See the rules for determining content language, rule 7 (first enabled language branch) is really the default language.
  2. Activate language detection based on browser preference (pageUseBrowserLanguagePreferences="true" in web.config).

Testing the configuration

Test the configuration by following the instructions below:

  1. Open Internet Explorer and select Internet Options from the Tools menu. Click Languages in the History group box and select the language preference. You should be redirected to the correct language, if your language selection can be matched to a content language.

Scenario 2 – local domains mapped to languages

This approach is when you want http://site.se to default to Swedish language without having the path in the URL contain the language. This approach requires configuration.

  1. Add the actual configuration, for example:
    XML
    <episerver.framework>
      <scanAssembly forceBinFolderScan="true" />
      <siteHostMapping>
        <siteHosts siteId="SomeMachine_CMS6">
          <add name="*" />
          <add name="www.site.com" language="en" />
          <add name="www.site.se" language="sv" />
        </siteHosts>
      </siteHostMapping>
  2. Add links or flags to the header or start page that link to other languages with their domain names.

The example shown above will set preferred content language for any requests to www.site.se to Swedish (SV). Note the first <add>, it is a “default” for any host name that does not match any other setting. It can contain a language attribute, but in this way you could use a www.site.com that uses browser language preferences as per scenario 1.

Scenario 3 – remember user preference

If you have a single domain and require the user language preference to be persisted, you can set a cookie with the current language selection. This means that the next time the user visits your site, they will also be redirected to the correct language. This may also be used if you, for example, are redirecting the user to another system, where language preference is not retained in the URL. You can set a cookie named epslanguage (see rules for content language) to make sure that the user gets the same language as before when returning to the site.

Be careful when using cookies and always try to build the website based on the concept that language is included in the URL. This will ensure that you never lose language context when the user is navigating your site.

Imagine that you have language cookie “No” and click the link from a friend that leads to the English site. You should of course continue to use the English site when surfing, so use cookies with care if you actually need them.

Language branches

A language branch has a unique identifier in the database to handle constraints, but is always exposed in APIs as a language code, for example “EN”. Language codes must therefore be unique: two language branches cannot use the same language code as the reverse lookup would fail.up would fail.

A content item, for instance a page, is created on a language branch and the first language created becomes the master language branch for that content. This applies to all content, globalized or not. The "master" contains all properties, both properties for that language and common properties. When new languages are created for a content item, they will only save properties that are specific for that language.

As a developer all languages will contain the common properties from the master version in the object, but they are not editable. If you change a property that should not be saved per language, you will get an exception when calling the IContentRepository.Save method if the language you are publishing is not the master language for that content.

Language-specific settings

Properties

Language-specific properties are defined by the administrator/developer on a content type. The metadata (for example, Name) that is language-specific cannot be changed and has been defined by the system. Metadata properties that relate to content are language-specific and metadata properties that relate to navigation are common.

For PageData, the following properties are defined per language:

  • PagePendingPublish endingPublish
  • PageWorkStatus
  • PageSaved
  • PageChanged
  • PageCreatedBy
  • PageChangedBy
  • PageCreatedSID
  • PageLanguageBranch
  • PageName
  • PageStartPublish
  • PageStopPublish
  • PageChangedOnPublish
  • PageCreated
  • PageLanguageID
  • PageExternalURL
  • PageURLSegment
  • PageShortcutType
  • PageShortcutLink
  • PageTargetFrame
  • PageLinkURL
  • PageDelayedPublish

You can programmatically check if a property is language-specific by checking IsLanguageSpecific on the PropertyData class (see samples for an example).

Page language settings

To help the system know which languages should be used on which part of the site, we have Page Language Settings, which actually define the languages that should be available to the editor when creating new pages. They also define fallback languages and replacement languages. The administrative API for page language settings are settings are EPiServer.DataAbstraction.PageLanguageSetting. The runtime API to read settings with support for inheritance is EPiServer.DataFactory.PageLanguageSettings. Page Language Settings does not restrict the languages that are rendered on the site, it only helps EPiServer make intelligent choices based on custom settings.

Note Language settings are currently only available for pages and not other content types like blocks.

Language selector

Languages are selected at runtime using the language selector class EPiServer.Core.LanguageSelector. A new instance of this class is created and passed to most methods in the global instance of DataFactory Global.EPDataFactory. Custom implementations of EPiServer.Core.ILanguageSelector can be used to get a customized language selection. The language selector uses the Page Language Settings, for example, to know when to fallback a missing language to another.

A language is considered available by the language selector if it has been published (CurrentPage.PendingPublish is false). The language selector does not check publish dates, so for example when a news item expires on one language, it is no longer displayed (no fallback to another language is applied).

Dynamic properties

Dynamic properties can also be made available per language. Dynamic properties do not use Page Language Settings and are always loaded with the same language as the page, so for example a Swedish page will always get Swedish dynamic properties (even if displayed on an English site due to fallback configuration).

Archiving page

A page is archived when an archive page has been set and the “Stop publish” date has passed. In the process the “Stop publish” date will be cleared. On globalized pages you have multiple “Stop publish” dates, but only the master language “Stop publish” dates are checked, and when the move is made to archive page, all “Stop publish” dates for all languages are cleared.s are cleared.

Subscription

When a language/page is updated, it will be sent information to all users that have the updated language as their current preference. The user’s language preference is determined from the property PersonalizedData.Language. If the user has no language preference, updates on the first found language are sent to the user. The user’s language preference can also be edited in admin mode for the user – this list is though filtered on current language files (XML resource files) in the Lang directory so make sure all languages have a resource file.

The subscription mailer sends a list of changed pages matching the subscription page and language preferences. These preferences are stored in the user profile’s SubscriptionInfo.SubscribedPages list.

Note The subscription is based on some special predefined properties, for example, “EPSUBSCRIBE” and “EPSUBSCRIBE-ROOT”, neither of these are supported as language specific.

Web browser preference

The web browser sends headers that inform the site of the languages that the user prefers. For example on a Swedish Internet Explorer the header will contain “SV”. If this feature is enabled in web.config/System Settings in the Admin view, EPiServer CMS will try to match this value to the language code that is enabled as a website language. An exact match is always preferred, for example a visitor with language preference English New Zealand (EN-NZ) will try to get an exact match, but will fallback to English (EN) if found instead.found instead.

Always use the ISO language codes, but in order to enable the fallback of user preference you may want to, for example, use language code “EN” for the English version that should be “master”-English.

Search

The search control earch control PageSearch supports searching on either all languages or a list of defined languages. The actual search does not use Page Language Settings as part of the search query, but will use Page Language Settings when selecting which language version of the page that should be displayed to the user.

No special treatment is used for files so if you have language-specific files, you must separate them in different directories.

Property searching (FindPagesWithCriteria)

The property search control earch control PropertySearch and the underlying APIDataFactory.FindPagesWithCritiera will search on all languages by default. However, the hits will use the same language selection process as any other page loading. You can control the following parameters:

  1. Search only on a specific language.
  2. Pass in language selector which will be used when returning the actual pages.

This lets you for example find a property only on a specific language branch.

See also

Do you find this information helpful? Please log in to provide feedback.

Last updated: Mar 31, 2014

Recommended reading