|
Article relates to
|
Sitefinity 3.2
|
|
Created by
|
Yasen Kiprov
|
HOW TO:
Change the default language when pages and content have already been created in different languages.
SOLUTION:
Using localization in Sitefinity, you can create pages and content (Generic Content, News, Blogs) in different languages. Normally, after you created pages and content in different languages, if you change the defaultCulture property, you get an error, caused by conflicts in the database. This article describes how you can manually correct some db tables in order to change the default site language in Sitefinity.
Pages
There are four tables in which language information is stored for cms pages and page templates:
- sf_CmsPageContent
- sf_PageContentBase
- sf_CmsCtrlLinks
- sf_StagedPageContent
The language field is called LangID and contains a number representing the language ID. The default culture to be changed, has ID 127 and is considered “invariant” while all other languages have different numbers. If you created pages in multiple languages, you have multiple records in these tables for each page.
For all IDs and related language codes, please see the table below.
Content
For generic content based modules (News items, Blog posts, Generic Content items) multiple language versions are also available.
The tables that contain language information are:
- sf_GCMetaData
- sf_CmsContentVersion
The rules applying for pages apply here as well: the default language version is called “invariant” and has ID 127, all other versions have different language IDs.
To change the default language, follow these steps:
1. In the <localization> section of the web.config, change the defaultCulture property to the desired new default language. For example, if your default language was English and you want set Spanish instead, you need to change the default culture from “en” to “es”.
2. Manually, or through a db query, iterate through all records in the 6 tables listed above and change the language ID from 127 to the real ID of the language. In the given example, you want to change from English to Spanish. So every record that has id = 127 is actually in English and you have to replace it with the actual English ID from the table below, which is 9.
IMPORTANT NOTE!
In the tables sf_PageContentBase and sf_CmsCtrlLinks, the records for page templates should not be changed. So, for every record in the above tables, you should check if it is a template or not. If it is a template, there is a record with the same ID in the sf_CmsTemplContent where templates are stored.
4. Repeat action 2, but this time changing the Spanish versions to “invariant”. You should do this by replacing the language ID from 10 to 127.
With these steps completed, your project should be upgraded and ready to run under the new default culture.
LANGUAGE IDs:
|
langID
|
2
|
9
|
27
|
22
|
13
|
10
|
7
|
8
|
16
|
|
code
|
bg
|
en
|
hr
|
ru
|
fr
|
es
|
de
|
el
|
it
|
More language codes you can find here:
CultureInfoClass
Please note that you have to translate them from hexadecimal to decimal numbers.