Our blog contains the activity stream of Orchard Dojo: general news, new resources or tutorials are announced here.

Featured tags

IIS
API
All tags >

How to localize content items? - Orchard Core Nuggets

So you want to create an Orchard Core website that presents its content in multiple languages. There are many parts of this, but what about content items? How do you make them ready for localization? We'll assume that you have your site already set up. We'll use the Page content type found in e.g. the Agency setup recipe as an example. First, make sure that you've set up available site cultures on the Orchard dashboard. This is under Configuration, Settings, Cultures (or the /Admin/Settings/localization URL). Set up LocalizationPart for content types to be localized as mentioned in the docs. Now comes the hard part: You need content items' URLs to be generated with the culture in it, so something like "en-US/demo". This is so you can have two versions of a content item, in different languages but with the same slug ("demo"). So, edit the settings of the Autoroute part from under the content type's editor under the Content menu on the admin, Content Definition, Content Types. For the Page type it's here: /Admin/ContentTypes/Page/ContentParts/AutoroutePart/Edit. There you need to change the default Autoroute pattern to include the culture's ID. This you can do by accessing the culture set in LocalizationPart, so the whole pattern will be something like this: {{ Model.ContentItem.Content.LocalizationPart.Culture }}/{{ Model.ContentItem | display_text | slugify }}. That's pretty much it. Now when you create a new Page you'll be able to tell Orchard which culture it belongs to and the URL will automatically reflect that. This is of course not the complete localization story. You'll also need to display the culture options to the user which you can do with the ContentCulturePicker shape as explained here. Other UI labels coming from code need to be localized too with PO files, as you can read about in the docs too. Have fun with your multi-language sites! We also have a follow-up post on how to add a culture URL segment for non-content pages. Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!