Dictionary Items
Depending on how your site is set up, not all content is edited through the Content section. There might be some text in your templates or macros that needs translation. Using Dictionary Items, you can store a value for each language. Dictionary Items have a unique key that is used to fetch the value of the Dictionary Item.
Dictionary Items can be managed from the Translation section. Let's take a look at an example. In this example, we will translate "Welcome to Umbraco" from within the template and add it to the dictionary:
Adding a Dictionary Item
To add a Dictionary Item:
- Go to the Translation section.
- Click on Dictionary in the Translation tree and select Create.
- Enter the Name for the dictionary item. Let's say Welcome.
- Click Create.
- Enter the values for the different language versions.
- Click Save.
Grouping Dictionary Items
To group dictionary items:
- Go to the Translation section.
- Click on Dictionary in the Translation tree and select Create.
- Enter the Name for the dictionary item. Let's say Contact.
- Click Create.
- Click on Contact and select Create.
- Enter the Name of the item to be created under the Contact group.
- Click Create.
- Enter the values for the different language versions.
- Click Save.
Fetching Dictionary Values
To fetch dictionary values in the template, replace the text with the following snippet:
@Umbraco.GetDictionaryValue("Welcome")
Alternatively, you can specify an altText
which will be returned if the dictionary value is empty.
@Umbraco.GetDictionaryValue("Welcome", "Another amazing day in Umbraco")
Using Dictionary Item in a Multilingual website
To use Dictionary Items in a multilingual website, see the Creating a Multilingual Site article.