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” />

 

Uma linguagem n√£o padr√£o est√° sendo utilizada no Sitecore e estourando exce√ß√Ķes. O que fazer?

Recentemente eu estive envolvido em um projeto de Sitecore, no qual na implementa√ß√£o do projeto foi definida uma linguagem n√£o padr√£o, no caminho /system/languages. A linguagem era “es-BR”(o idioma padr√£o para portugu√™s do Brasil √© pt-BR e n√£o es-BR. Eu pessoalmente recomendo utiliizar sempre as linguagens padr√Ķes, por√©m se esse n√£o for o seu caso continue lendo ūüėČ )

Quando o mecanismo de publiicação era disparado, o Sitecore estourava a seguinte exceção:

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)

Interessante que o mesmo erro estourava quando se tentava deletar o item da arvore de conte√ļdo, e estava se tornando um problema para os editores de conte√ļdo. Enquanto eu investigava o problema eu notei que a linguagem n√£o aparecia no item “Globalization” do painel de controle do Sitecore, mas aparecia na √°rvore de cont√ļdo.

O que eu tive que fazer para resolver este problema foi registrar a linguagem no Windows. Para fazer isso voce pode utilizar a ferramenta Language Registration, disponível  na marketplace da Sitecore. Após registrar este idioma eu tive que adicionar a entrada do idioma no arquivo App_Config\LanguageDefinitions.config:

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

A partir dai foi possível excluir o idioma sem problemas.