I took a look at the source code and managed to make it work.
This is the code for the umbraco.library.GetDictionaryItem
But when you want to use this in an actionhandler it doesn't work.
HttpContext.Current.Items["pageID"]
Code:
public static string GetDictionaryItem(string Key)
{
try
{
string pageId = HttpContext.Current.Items["pageID"] as string;
Domain[] domains = GetCurrentDomains(int.Parse(pageId));
if (domains != null)
{
if (domains.Length > -1)
{
return new Dictionary.DictionaryItem(Key).Value(domains[0].Language.id);
}
}
return new Dictionary.DictionaryItem(Key).Value();
}
catch (Exception errDictionary)
{
HttpContext.Current.Trace.Warn("library", "Error outputting dictionary item '" + Key + "'",
errDictionary);
return string.Empty;
}
}
So to have a version working an an actionhandler you need to pass the documentobjectid.
Code:
public string GetDictionaryItem(string Key, int id)
{
try
{
string pageId = id.ToString();
Domain[] domains = umbraco.library.GetCurrentDomains(int.Parse(pageId));
if (domains != null)
{
if (domains.Length > -1)
{
return new umbraco.cms.businesslogic.Dictionary.DictionaryItem(Key).Value(domains[0].Language.id);
}
}
return new umbraco.cms.businesslogic.Dictionary.DictionaryItem(Key).Value();
}
catch (Exception errDictionary)
{
HttpContext.Current.Trace.Warn("library", "Error outputting dictionary item '" + Key + "'",
errDictionary);
return string.Empty;
}
}
So in the actionhandler I just do:
GetDictionaryItem("MailAdminPublish",documentObject.Id);
Umbraco tips and tricks:
http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional