Localization and internationalization
The Sense/Net Content Repository and view technolgies are highly flexible in terms of displaying texts in various languages. By default Sense/Net includes English and Hungarian translations of the different string resources but a new language can easily be added by localizing string resources. You can read more about how to localize Sense/Net here:
In the demo structure most of the displayed texts come from string resources meaning that they can be translated to any language. The following article helps you in creating pages/controls that can easily be localized by builders, translators:
Setting the current language
The following sections list the different methods of choosing the language that the portal uses to display information. The priority of these methods is the following:
- user based culture (if enabled and set)
- otherwise browser-based culture (if enabled)
- otherwise site language
Setting the language of a site
You can define new languages in the Content Type Definition of the Site Content Type. The following is the default setting defining English and Hungarian languages in the CTD of the Site, this can be freely customized:
<Field name="Language" type="Choice"> <DisplayName>Language</DisplayName> <Description>Please define the default language of this site</Description> <Configuration> <AllowMultiple>false</AllowMultiple> <AllowExtraValue>false</AllowExtraValue> <Options> <Option value="en" selected="true">English</Option> <Option value="hu">Hungarian</Option> </Options> </Configuration> </Field>
Setting the language of a specific Site can be done by editing the value of the Language Field of the Site:
Setting a dialect of a language
You can define dialects as the languages in the Content Type Definition of the Site Content Type. If You want to set a dialect, define a new language option and complete it with the dialect abbreviation
<Options> <Option value="en-GB" selected="true">British English</Option> <Option value="en-US" selected="true">American English</Option> <Option value="hu">Hungarian</Option> </Options>
In resource xml define a new language-variant to the dialects
<Language cultureName="en"> <data name="FootballText" xml:space="preserve"> <value>Football</value> </data> </Language> <Language cultureName="en-GB"> <data name="FootballText" xml:space="preserve"> <value>Football</value> </data> </Language> <Language cultureName="en-US"> <data name="FootballText" xml:space="preserve"> <value>Soccer</value> </data> </Language>
If the choosen dialect cannot be found in string resources there is an automatic fallback to the language without dialect abbreviation.
Set site language by user settings - from version 6.3
If you want your site to appear according to the users' own profile settings check the Enable user-based culture checkbox on your sites' Edit page:
If the checkbox is checked the site shows up in a language that the user has chosen on his/her profile page (the setting is stored on the user content itself).
If the chosen language cannot be resolved (by the .NET framework) the portal will try to use the browser or site settings, as you can see in the following section.
If the chosen language does not exist in string resources the string resources will appear with their default display.
Set site language by browser settings
If you want your site to appear according to the users' browser culture settings check the EnableClientBasedCulture checkbox on your sites' Edit page:
If the checkbox is checked the site shows up in the first language from the browsers 'Language preferences' that is in the correct format. Browsers send the language information in the Accept-Language header in the following format (the quality values displayed in the example are ignored):
Accept-Language: da, en-gb;q=0.8, en;q=0.7
For details about the language header and how to set it please visit the following article:
If the user browser's language cannot be resolved (by the .NET framework) the site shows up with the default language of the site.
If the user browser's language does not exist in string resources the string resources will appear with their default display:
If you don't want to display the string resources with their default display, you can set a default language to be used. This can be achieved by setting the FallbackCulture element in the web.config, for example:
<!-- Default language for a string resource if no language variant is found for the current language. Leave it empty to display resource info (class, key) for non existing language variants or set it to a language (eg. "en") to display non existing language variants in a default language. --> <add key="FallbackCulture" value="en"/>
There are no external references for this article.