10 January 2024 | Content management, Tech

Adding a translation for a new node in Umbraco 7

Author: Mossy Breen

Umbraco 7 has a unique way of handling multilingual content on a website. It’s not quite obvious at first, and took me some time fumbling around to understand what was going on. I am documenting it here for future posterity and to help any others scratching their heads at this too. I believe newer versions of umbraco handle this better, so this post is targeted at Umbraco 7.

Background

We have a multilingual site set up for a customer with English and Irish (Gaeilge) language home nodes and all their children.

The best way to get up and running initially is to create all your content in a single language, and then copy the home node to a new language with the following checkboxes set to yes. (Relate to original, Include descendants). This will ensure there is a relationship between the original node and the copied node (this is important for later). You then translate the newly created content (manually or via the XML translation function built into umbraco 7).

Creating a translation for a single node

Here is where I got stuck initially, but it turns out to be straight forward once I understood what was happening in the background. You can complete this is the same way as above, but for a single node.

  1. Identify the content node that does not have an associated translation.
  2. Right click, click Copy
  3. Ensure “Relate to original” is checked  (This creates a relationship in the cmsRelations table in the database)
  4. Choose an appropriate location for the copy in the other language site. It doesn’t need to be in the exact same position in the tree structure as the other language, but it’s probably wise to keep the various language structures similar.
  5. Now go and edit the copy and replace the content with your translated content. Publish!

Now for some “magic”

In order to ensure the language variant of your page appears as a link on your public facing site, you need to add some code to your umbraco site and template. The following package provides the code required to show the alternative language on your page (in the main navigation area or elsewhere).

Multi Language tools

You would then add something like the following to display language variants of the page the user is on.

The magic lies in what this code does. There is no explicit “language/translation relationship” in umbraco, but if two nodes are related and they are in different languages, then it is assumed that they are language variants and lists out a link to those variants. Quite nice.

You can review relationships from the “Developer” section of umbraco: Under “Relation types” and on the “Relations” tab. There is a list of all relations here. Unfortunately there isn’t a way to edit or delete this data from within the UI. I have resorted to fixing up some broken relationships at the database level in the cmsRelations table.

There may be better ways to achieve a cleaner “translation” relationship, but it doesn’t come out of the box so we’re stuck with this implementation. It works but feels a little fragile and would likely break if we were try to add more ways to relate content to other content.

The relationship blog post on umbraco describes alternative solutions to this. It is written for an earlier version of umbraco, but I think it is still relevant to Umbraco 7.

Call us!

Whether you have a specific need now or would like to explore, in general,
how custom software solutions might support your progress we'd love to talk.

Request a Callback