Get dictionary items in your IApplicationEventHandler events
Hi
We are busy setting up a brand new umbraco 6 site. I have some events i've wired up through the IApplicationEventHandler. Everything is working as expected.
Except for getting dictionary items in these events. I've tried umbraco.library.GetDictionaryItem("myKey"), i've tried to mess around with LocalizationService.GetDictionaryItemByKey, but I can't get my head around this. They all retrun empty results or throw exceptions telling me the keys don't exist.
In the end I ended up using the old API's. This was the working code I ended up with:
int languageId = MyEvents.LanguageHelpers.GetLanguageId(publishedEntry.Id); var subject = (new umbraco.cms.businesslogic.Dictionary.DictionaryItem("myDictKey")).Value(languageId);
Where the GetLanguageId does nothing more than
Domain[] domains = umbraco.library.GetCurrentDomains(pageId); if (domains != null && domains.Length >= 0) { return domains[0].Language.id; //yes lowercase id }
If you have a better solution using the v6 Api, please let it know.
Does anybody know if this has been updated in version 7? I am trying to find any info I can on the latest API method for this but keep getting routed back to this thread.
Yes, lots of fun, funky stuff in this one! Many different sites in one instance with some sites having their own multilingual capabilities.
In this scenario, the page is loading, calling a surfacecontroller to load a form which sets up to post back to the same controller. So state is being lost, which means no localization. The form is using a custom Umbraco.Web.Mvc.UmbracoViewPage
But this means that I have to get the Dictionary terms by key as well as the Umbraco Table's id for that language. I have a solution passing the culture along and hitting the database to get the corresponding language id. I am just curious if there was a native (to umbraco) method to call and pass in the key and language id. I have used the same method as you mentioned earlier but still wonder if this hasn't been updated.
What namespace is that Service located? Gave it a quick try, but need to find out where it is.
Get dictionary items in your IApplicationEventHandler events
Hi
We are busy setting up a brand new umbraco 6 site. I have some events i've wired up through the IApplicationEventHandler. Everything is working as expected.
Except for getting dictionary items in these events. I've tried umbraco.library.GetDictionaryItem("myKey"), i've tried to mess around with LocalizationService.GetDictionaryItemByKey, but I can't get my head around this. They all retrun empty results or throw exceptions telling me the keys don't exist.
Has anyone and idea how to do this?
Kind regards
Comment author was deleted
Try setting the correct culture first
Comment author was deleted
If you want to fetch the culture based on a node check http://our.umbraco.org/forum/developers/xslt/4747-How-do-you-retrieve-the-Culture-Code-for-a-given-Node
Hi,
I tried things like this using the v6 API. But I never got that working, probably because I need to polish my knowledge still a bit on it.
I should probably have done something like Tim said:
In the end I ended up using the old API's. This was the working code I ended up with:
Where the GetLanguageId does nothing more than
If you have a better solution using the v6 Api, please let it know.
Does anybody know if this has been updated in version 7? I am trying to find any info I can on the latest API method for this but keep getting routed back to this thread.
The LocalizationService is available in v7:
you should be able to use this. The issue you might face, which language is being handled.
If the application is starting up, you probably don't need languages anyway. Unless you need funky stuff. What issue you trying to solve?
Yes, lots of fun, funky stuff in this one! Many different sites in one instance with some sites having their own multilingual capabilities.
In this scenario, the page is loading, calling a surfacecontroller to load a form which sets up to post back to the same controller. So state is being lost, which means no localization. The form is using a custom Umbraco.Web.Mvc.UmbracoViewPage
But this means that I have to get the Dictionary terms by key as well as the Umbraco Table's id for that language. I have a solution passing the culture along and hitting the database to get the corresponding language id. I am just curious if there was a native (to umbraco) method to call and pass in the key and language id. I have used the same method as you mentioned earlier but still wonder if this hasn't been updated.
What namespace is that Service located? Gave it a quick try, but need to find out where it is.
So you are not trying to access the Dictionary from IApplicationHandler events? That was what the forum post was about.
is working on a reply...