Globalization scenarios
Describes common globalization scenarios for Optimizely Content Management System (CMS) solutions, and provides an overview of language-specific settings and properties for CMS content.
Scenario 1 – Global domain with multiple languages
You want visitors to go to the official site.com
address, but need to display different content depending on their language selection.
- Set a default language that most of your visitors understand (normally English for a global site).
- Activate language detection based on browser preference (set
GlobalizationSettingsOptions.UseBrowserLanguagePreferences
to true). - Test the configuration.
- Go to the language settings options in your web browser.
- Select the language preference. You are redirected to the correct language if your language selection matches a content language.
Scenario 2 – Local domains mapped to languages
Use this approach when you want http://site.se
to default to the Swedish language without having the path in the URL contain the language. Add each hostname and map them to culture under Manage Websites in the CMS admin view.
Scenario 3 – Remember user preference
If you have a single domain and must persist the user language preference, set a cookie with the current language selection. The next time a visitor visits your site, the visitor is redirected to the correct language. You also may use this to redirect the visitor to another system where language preference is not retained in the URL. You can set a cookie named epslanguage
 to make sure that the visitor gets the same language as before when returning to the site.
Note
Be careful when using cookies and always try to build the website based on the concept that language is included in the URL. This ensures 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 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 be unique: two language branches cannot use the same language code because the reverse lookup 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 languages are created for a content item, each saves only properties that are specific to that language.
As a developer, languages 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, an exception occurs when you call 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 or developer on a content type. The metadata (for example, Name) that is language-specific cannot be changed and was defined by the system. Metadata properties related to content are language-specific, and metadata properties related 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.
Content language settings
To determine the languages to use on which part of a site, use the Content Language Settings, which define the languages that are available to the editor when creating content. The settings also define fallback languages and replacement languages. The administrative API for content language settings is EPiServer.DataAbstraction.ContentLanguageSettingRepository
. The runtime API to read settings with support for inheritance is EPiServer.Core.IContentLanguageSettingsHandler
. Content language settings do not restrict the languages that are rendered on the site; it only helps Optimizely make choices based on custom settings.
Note
Language settings are only available for pages and not other content types like blocks.
Language options in the API
Languages are selected at runtime using a language selection process. You can customize the options used for the language process by using the LanguageLoaderOption
passed to IContentRepository
.
A language is considered available by the language loader if it was published (CurrentPage.PendingPublish
is false). The language selector does not check publish dates, so for example, when a news item expires in one language, it is no longer displayed (no fallback to another language is applied).
Dynamic properties (Legacy feature)
You can make dynamic properties available per language. Dynamic properties do not use Page Language Settings and are loaded with the same language as the page. For example, a Swedish page gets Swedish dynamic properties (even if displayed on an English site due to fallback configuration).
Archive page
A page is archived when an archive page is set and the Stop publish date has passed. In the process the Stop publish date is 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 the archive page, Stop publish dates for all languages are cleared.
Web browser preference
The Web browser sends headers informing the site of the user's preferred languages. For example, the Accept-Language header might contain SV for a Swedish user. If this feature is enabled in GlobalizationSettingsOptions.UseBrowserLanguagePreferences
, CMS tries to match this value to the language code that is enabled as a website language. An exact match is preferred, such as a visitor with language preference English New Zealand (EN-NZ) tried to get an exact match, but falls back to English (EN) if found instead.
Note
Always use the ISO language codes, but to enable the fallback of user preference, you may want to use language code EN for the English version that should be master-English.
Search
The PageSearch
search control supports searching on all languages or a list of defined languages. The actual search does not use Page Language Settings as part of the search query but uses Page Language Settings when selecting which language version of the page that should be displayed to the visitor.
No special treatment occurs for files, so if you have language-specific files, you must separate them into different directories.
Property searching (FindPagesWithCriteria)
The PropertySearch
search control and the underlying APIDataFactory.FindPagesWithCriteria
 search on all languages by default. However, the hits use the same language selection process as any other page loading. You can control the following parameters:
- Search only on a specific language.
- Pass in language selector, which is used when returning the actual pages.
This lets you find a property that is only on a specific language branch.
Updated 5 months ago