Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbraco 7 Working with languages/Dictionary

Our project has finally come to a point where we can add translations. I just cant seem to figure out how to actually work with languages in Umbraco 7. Ive added a language and a few dictionary items in the backend, but how do i select the givent language in my code?

Are there any helpers to get translations in the API? Like DictionaryHelper.Translate("Answers","da-DK"); ? Or similar? Is there a way to set the language, etc in the startup controller, and just always get that language from the dictionary?

Thanks in advance. Jonas.

like image 247
Jonas m Avatar asked Apr 07 '15 09:04

Jonas m


1 Answers

First, you have to create your languages under Settings > Languages.

Next step is to set the language on each node, or just on a top node. So lets say your content tree looks like this:"

enter image description here

Then right click on "da" and select "Culture and Hostnames". Select "da-DK" for this node. All subnodes (and "da" node) will now have the danish language.

So now its simple to get dictionary items in razor and c# code. In razor:

@Umbraco.GetDictionaryValue("Answers")
like image 177
Morten OC Avatar answered Oct 27 '22 01:10

Morten OC