1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Changing default language

Changing default language

6 posts, 1 answered
  1. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    10 Nov 2009
    Link to this post
    I have a website based on Sitefinity 3.6, and I need to change the default language.
    I should mention that all content is created and the site is live. I have read on a different post that default language cannot be changed.

    If I change the defaultCuture attribute in web.config and load the home page, I get "An item with the same key has already been added" error.

    Is there any workaround for this ?

    Thanks.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Nov 2009
    Link to this post
    Hi Constantin Aparaschivei,

    Thank you for using our services.

    The default language can be changed, however you would need to run some SQL scripts against the database in order to completely achieve this. Before you begin, please backup the project and DB and try this on a local environment.

    Here is some sample SLQ script how to change the default language for Sitefintiy site. Please read the in-line comments. The sample is for changing the default language from English to Bulgarian:
    declare @oldDefaultLangId int
    declare @newDefaultLangId int
      
    set @oldDefaultLangId = 9 -- the LCID of the previous default culture, 9 is for en
    set @newDefaultLangId = 2 -- the LCID of the new default culture, 2 is for bg
      
    -- Convert pages
    Update sf_PageContentBase set LangID = @oldDefaultLangId where LangID = 127 and ItemType = 'CmsPageContent'  
    Update sf_PageContentBase set LangID = 127 where LangID = @newDefaultLangId and ItemType = 'CmsPageContent'     
       
    Update sf_CmsPageContent set LangID = @oldDefaultLangId where LangID = 127   
    Update sf_CmsPageContent set LangID = 127 where LangID = @newDefaultLangId   
        
    Update sf_StagedPageContent set LangID = @oldDefaultLangId where LangID = 127 and ID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent'
    Update sf_StagedPageContent set LangID = 127 where LangID = @newDefaultLangId and ID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent'
        
    Update sf_CmsCtrlLinks set LangID = @oldDefaultLangId where LangID = 127 and PageID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent'
    Update sf_CmsCtrlLinks set LangID = 127 where LangID = @newDefaultLangId and PageID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent')    
         
    Update sf_StagedCtrlLinks set LangID = @oldDefaultLangId where LangID = 127 and PageID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent'
    Update sf_StagedCtrlLinks set LangID = 127 where LangID = @newDefaultLangId and PageID in (select ID from sf_PageContentBase where ItemType = 'CmsPageContent'
        
      
    -- Convert generic content items.
    -- You should run this script if you have generic content modules with enabled localization in the web.config.
    -- In the IN clause specify the application names of the generic content providers with content with allowLocalization attribute set to true.
    -- For example: '/', '/News'
    Update sf_GCMetaData set LangID = @oldDefaultLangId where LangID = 127 and Application in ('/', '/News'
    Update sf_GCMetaData set LangID = 127 where LangID = @newDefaultLangId and Application in ('/', '/News'
         
    Update sf_CmsContentVersion set LangID = @oldDefaultLangId where LangID = 127 and Application in ('/', '/News'
    Update sf_CmsContentVersion set LangID = 127 where LangID = 9 and Application in ('/', '/News'
         
    Update sf_CmsTextContent set Culture = @oldDefaultLangId where Culture = 127 and Application in ('/', '/News'
    Update sf_CmsTextContent set Culture = 127 where Culture = @newDefaultLangId and Application in ('/', '/News'
        
    Update sf_VersionItem set CultureID = @oldDefaultLangId where CultureID = 127 and Application in ('/', '/News'
    Update sf_VersionItem set CultureID = 127 where CultureID = @newDefaultLangId and Application in ('/', '/News'
        
    Update sf_VrsTxtData set CultureID = @oldDefaultLangId where CultureID = 127 and Application in ('/', '/News'
    Update sf_VrsTxtData set CultureID = 127 where CultureID = @newDefaultLangId and Application in ('/', '/News'
       
    Update sf_VrsBinData set CultureID = @oldDefaultLangId where CultureID = 127 and Application in ('/', '/News'
    Update sf_VrsBinData set CultureID = 127 where CultureID = @newDefaultLangId and Application in ('/', '/News')

    You can find a table with all .NET supported culture LCIDs on the following page. Please note that on the page those IDs are in hexadecimal numbers, so you should convert the desired one in decimal.

    When you get the error you are getting, if you navigate to a different page (say ~/Sitefinity/default.aspx) the error should not appear anymore.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    16 Nov 2009
    Link to this post
    After running the script I have some generic content that cannot be used anymore, it is displayed in the list with name, author and description "undefined".
    Is the script missing anything ?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Nov 2009
    Link to this post
    Hi Constantin Aparaschivei,

    Thank you for getting back to me.

    The script is not missing anything. The undefined means that the content manager pulls out empty metafields for the content items. Is it possible that you have applied this script on generic content modules where you had not had localization enabled? This script has been used by a lot of  clients before and they did not have problems with it. Could you open a support ticked and send us over the original DB (I hope you have backed it up before you ran the script) and your original web.config file? We will run the script against the DB and update it with the new default culture for you.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Constantin Aparaschivei
    Constantin Aparaschivei avatar
    27 posts
    Registered:
    10 Nov 2009
    17 Nov 2009
    Link to this post
    The problem is only for 4 generic content modules, not all of them. I am not sure localization was enabled for them, but I can create that modules again, the rest of the web site works perfect.

    Thanks for your answer,
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Nov 2009
    Link to this post
    Hi Constantin Aparaschivei,

    Go to the web.config and check if those generic content based modules have the allowLocalization="true" set to them. If they don't and you have run the script against them then this is the reason you are getting those metafields empty. You do not have to run the script against non localized modules:
    <add name="News" allowLocalization="true" urlRewriteFormat="ID={GUID}" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" allowComments="true" applicationName="/News" versioningProviderName="" commentsModeration="true" allowWorflow="true" connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data" />

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 1 answered