Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Translate categories

Vote:
 

Is it possible to translate the names or descriptions of categories? I've found a blog post on how to do it in EPi 6 by putting the translations in a language file but I can't get the same thing to work in EPiServer 7. Is there a new better way to work with categories and globalization?

#73165
Jul 09, 2013 12:01
Vote:
 

Hi Oskar,

Dit you use this format?

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<languages>
  <language name="dutch" id="nl">
    <categories>
      <category name="CategoryName">
        <description>CategoryName translated</description>
      </category>
    </categories>
  </language>
</languages>

 

To do some shameless self promotion: You could also install a NuGet package I created, that allows you to create your translations within the content tree, also for categories.

http://nuget.episerver.com/en/OtherPages/Package/?packageId=EPiServer.Libraries.Localization

http://jstemerdink.wordpress.com/2013/06/20/a-custom-localization-provider-for-episerver-7-2/

 

Hope this helps.

#73168
Jul 09, 2013 13:12
Vote:
 

Yes, that was the xml I tried earlier and I still can't get it to work.

In view mode I use the code below but it only lists the names of the categories.

@Html.PropertyFor(m=>m.Category)

And when I edit the page in forms mode the category descriptions are used but they are not translated.

I have translations of page types and properties so I know the language file works.

#73170
Jul 09, 2013 14:11
Vote:
 

The property for displaying translated categories is LocalizedDescription, so maybe it should be: m.Category.LocalizedDescription ?

#73171
Jul 09, 2013 14:32
Vote:
 

PagaData.Category don't seem to have LocalizedDescription. And view mode isn't really the problem because there I can translate them myself. I was hoping I would be able to translate them in edit mode as well, but maybe that's not possible?

#73179
Jul 09, 2013 15:39
Vote:
 

Ah, must have been sleeping. PageData.Category is CategoryList, so it contains the categories, if any are selected. The LocalizedDescription is a property of a category not of the CategoryList (a.k.a. Category)

#73180
Jul 09, 2013 15:53
Vote:
 

Thank you for all the help, I can get the translated descriptions from the language file by doing something like this:

Model.Category.Select(x=> Category.Find(x).LocalizedDescription)

But the translations are still not shown in edit mode though.

 

#73184
Jul 09, 2013 16:38
Vote:
 

No prob. I think to show them in EditMode, you will need to switch the UI language.

#73185
Jul 09, 2013 16:44
Vote:
 

Both the language file and the UI culture are "en". And property names are translated correctly in edit mode. I'm starting to think that this is a bug in episerver.

#73187
Jul 09, 2013 17:17
Vote:
 

No, i don't think that is the same bug. My site language is english.

#73197
Jul 10, 2013 10:00
Vote:
 

Hi, 

I have started working on Localizing the EPiServer Categories, and Category.Find(x).LocalizedDescription works like a charm. Thank you for the suggestion. However while displaying the category description on an Html page , I had to do HttpUtility.HtmlDecode(Category.Find(@tag.Key).LocalizedDescription) as it was displaying & as &amp;

#138912
Sep 23, 2015 13:21
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.