Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
How does EPiServer CMS know which language to display to visitors? The short answer is that EPiServer CMS enforces the language to be visible in the URL, either in the path or the domain part of the URL.
The reasons for this are simple:
There are also some technical reasons such as output caching in .NET and web browser caching on the client that expect a single URL to render the same content to anonymous users.
There are three different language concepts in EPiServer, two which are defined by ASP.NET (culture and uiCulture), and one which is the EPiServer CMS content language. Refer to the ASP.NET culture as “System Language” and uiCulture as “User Interface Language”. All languages and language settings are expressed as Cultures (as defined by the .NET CultureInfo object). A typical culture is “EN-US” which defines the language as English (EN) with the culturally defined specifics for United States (US). You may in some cases only define the language, such as “SV” which defines the neutral culture Swedish.
The content language controls which language version of the page content that is displayed, it can be a neutral culture or a specific culture. The preferred content language is determined by the following rules:
The system language determines how listings are sorted, how to format date and time, etc. Since these types of formatting rules are culturally dependent, the system language must not be a neutral culture. The system language is determined by the following rules:
In case you want to customize the selection logic, you can modify CurrentCulture in the InitializeCulture() method (virtual method on System.Web.UI.Page). Our default implementation is done in EPIServer.PageBase
The user interface language is only used to pull out localized texts in the ASP.NET application, it will define the majority of the texts in Edit and Admin mode of EPiServer CMS, but for a site visitor the user interface language will only apply to minor elements such as texts on buttons. For a visitor the majority of information is usually content, which is defined by the content language. The user interface language is determined by the following rules:
In case you want to customize the selection logic, you can modify CurrentUICulture in the InitializeCulture() method (virtual method on System.Web.UI.Page). Our default implementation is done in EPIServer.PageBase.
This section outlines some recommended globalization scenarios and describes how to manage them.
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.
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.
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).
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.
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 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.
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. However, use this with caution as overusage of dynamic properties is not recommended as it may negatively affect performance. Only use dynamic properties for administrative settings that must be done 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.
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.
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 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 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: Mar 25, 2013