Automatically set the language of the content editor

In a recent build we had a request from the client to automatically set the language of the content editor based on where in the tree they were viewing. The rules for selecting the language were quite simple:

– sitecore
— Content
— English site – field with value for default language set to be ‘en’
— French site – field with value for default language set to be ‘fr-fr’

If the user was making changes within the English site, they wanted the Content Editor to default to ‘en’. If they were editing within the French site, they wanted the Content Editor to default to ‘fr-fr’.

With the help of support, the following solution was suggested:

  1. Create your own class inherited from Sitecore.Shell.Applications.ContentManager.ContentEditorForm
  2. Add a new method:
  3. Edit \sitecore\shell\Applications\Content Manager\Default.aspx, changing the sc:CodeBeside reference to point to your new class:

    Note, you need to keep the CodeBeside reference on one line as per the out the box version (the other controls are eg DataContext, RegisterKey etc)
  4. Edit \sitecore\shell\Applications\Content Manager\Content editor.js, adding a call to your new method. This needs to happen in the onTreeNodeClick method after LoadItem.

One thought on “Automatically set the language of the content editor

  1. Pingback: Language settings in Sitecore | Sitecore Martina

Leave a Reply

Your email address will not be published.