Non-default language is being used in Sitecore and is causing it to throw exceptions. What to do?

Recently I have been involved in a Sitecore project where in the implementation of the project a non-default language was created under system/languages called es-BR(Sitecore’s brazilian portuguese definition is pt-BR. I highly suggest that you use the standard notation but if you don’t have that option keep reading 😉 ).

When the publish mechanism got triggered Sitecore would throw the following exception:

Message: Item cannot be renamed to ‘es-BR’ as it is not a valid language name.

Source: Sitecore.Kernel

   at Sitecore.Diagnostics.Assert.IsTrue(Boolean condition, String message)

   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)

   at Sitecore.Data.Engines.EngineCommand`2.RaiseEvent[TArgs](EventHandler`1 handlers, Func`2 argsCreator)

   at Sitecore.Data.Engines.EngineCommand`2.RaiseExecuting(Boolean& cancelled)

   at Sitecore.Data.Engines.EngineCommand`2.CanExecute()

   at Sitecore.Data.Engines.EngineCommand`2.Execute()

   at Sitecore.Data.Engines.DataEngine.SaveItem(Item item)

   at Sitecore.Data.Managers.ItemProvider.SaveItem(Item item)

   at Sitecore.Data.Items.ItemEditing.AcceptChanges(Boolean updateStatistics, Boolean silent)

   at Sitecore.Data.Items.ItemEditing.EndEdit(Boolean updateStatistics, Boolean silent)

   at Sitecore.Data.Items.EditContext.Dispose()

   at Sitecore.Publishing.PublishHelper.CopyToTarget(Item sourceVersion)

   at Sitecore.Publishing.PublishHelper.PublishVersionToTarget(Item sourceVersion, Item targetItem, Boolean targetCreated)

   at Sitecore.Publishing.Pipelines.PublishItem.PerformAction.ExecuteAction(PublishItemContext context)

   at Sitecore.Publishing.Pipelines.PublishItem.PerformAction.Process(PublishItemContext context)

   at (Object , Object[] )

   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)

   at Sitecore.Publishing.Pipelines.PublishItem.PublishItemPipeline.Run(PublishItemContext context)

   at Sitecore.Support.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable`1 entries, HashSet`1 publishedReferredItems, PublishContext context, Boolean processReferencedItems)

   at Sitecore.Support.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable`1 entries, HashSet`1 publishedReferredItems, PublishContext context, Boolean processReferencedItems)

   at Sitecore.Support.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable`1 entries, HashSet`1 publishedReferredItems, PublishContext context, Boolean processReferencedItems)

   at Sitecore.Support.Publishing.Pipelines.Publish.ProcessQueue.ProcessEntries(IEnumerable`1 entries, HashSet`1 publishedReferredItems, PublishContext context, Boolean processReferencedItems)

   at Sitecore.Support.Publishing.Pipelines.Publish.ProcessQueue.Process(PublishContext context)

Interestingly the same error would be throw if you would try to delete it from the content tree. While I was investigating how I could address this issue I noticed that the language would not appear on Sitecore’s Control Panel /Globalization menu, but it would show on the content tree.

What I had to do to fix that was to ensure that the language was registered in the Windows system. You could use the Language Registration tool available in the Sitecore’s marketplace. After that I had to add the node to \App_Config\LanguageDefinitions.config file:

<language id=”es” region=”BR” codepage=”65001″ encoding=”utf-8″ charset=”iso-8859-1″ icon=”flags/16×16/flag_Brazil.PNG” />

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s