This document outlines some common globalization scenarios for EPiServer CMS solutions, and provides an overview of language-specific settings and properties for CMS content.
You want all your visitors to go to the official “site.com” address, but need to display different content depending on their language selection.
Test the configuration by following the instructions below:
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.
<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>
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.
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.
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 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:
You can programmatically check if a property is language-specific by checking IsLanguageSpecific on the PropertyData class (see samples for an example).
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.
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 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).
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.
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.
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.
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.
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:
This lets you for example find a property only on a specific language branch.
Last updated: Feb 23, 2015