27.09.11

Using the Umbraco dictionary with GUI controls

Umbraco's multilingual infrastructure can be easily used with combined ASP.NET GUI controls. With the belonging source code, translation relevant elements can be preoccupied with corresponding entries from the Umbraco dictionary. This is done inside the OnInit() method:

protected override void OnInit(EventArgs e)
{
    btnSearch.InnerHtml = getDictionaryItem("cwsSearch");
}

The helper-method getDictionaryItem() takes over all required tasks related to the communication with the Umbraco-API:

private string getDictionaryItem(string key)
{
    string result = umbraco.library.GetDictionaryItem(key);
    if (String.IsNullOrEmpty(result)) result = "[#" + key + "]";
    return result;
}