after i compile i put the dll in the umbraco bin folder and everything is working well. for the site i define host name and new language as i did few times before. the problem is that it gets only the english values from the dictionary, although the host name are defined as different culture.
other things are not making the problem, for example in one of the macro i'm also getting dictionary like this:
var errMessage = "<xsl:value-of select='umbraco.library:GetDictionaryItem("RV.message")' />";
and it takes the RIGHT dictionary values.
i looked at the umbraco.library.GetDictionary function and the language defined in the code like this:
Language byCultureCode = Language.GetByCultureCode(Thread.CurrentThread.CurrentUICulture.Name);
so i guess that everything is because that the CurrentUICulture is defined as english. maybe because my OS is in english? or maybe because my umbraco backend is in english?
I'm a bit too new to Umbraco to know how to set a currentUICulture, but perhaps you could extend the library and add a method which allows a culture to be passed in?
about the RVContactForm - please post a messge in the forum of the package and i will help as much as i can.
about this problem - i guess i can extend the method and send a culture, but the whole idea is that the culture will not be hardcoded, and will be dynamic, so this kind of solution may work to my specific case, but not for others. i'm trying to avoid hard-coded culture assigments.
I'm not too worried about taking a shortcut for this project and you might be better off considering if there is a longer term solution. I want the NodeId to allow me to customise the email meta information depending on the node the macro is embedded in, which is why it makes a bit more sense for me to do it this way.
I'm not planning on updating this version of Umbraco for some time to come as I have had to make other tweaks also, but it would certainly be good to merge this one into the core.
as far as i understand, the "CurrentThread.CurrentCulture" is defined by the hostname culture that you can configure from umbraco.
the "CurrentThread.CurrentUICulture", is defined by the operation system of the user.
the function umbraco.library.GetDictionaryItem is getting the dictionary item that match to the CurrentUICulture.
this facts is the reason for my and probably yours - problem - i configure hostname as hebrew and my OS in english, so the dll alwayes bring the english dictionary items instead of the hebrew ones as expected.
so, i'd prefer not to change the umbraco.library source code (for future comptibilaty). instead, i add it as a feature request to the umbraco team. in my package, i add at the beggining of the asmx code:
var originalUICulture = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
Thanks Martin for all the help, the solution is actually similar to your approach - in order to access the correct dictionary items from the web service, we must get the umbraco language id from the XSLT (this id is different from LCID - it comes from the umbraco table umbraco.languages).
wrong dictionary is loaded (from webservice dll)
hi,
i developed an asmx webservice that uses dictionary items like that:
after i compile i put the dll in the umbraco bin folder and everything is working well.
for the site i define host name and new language as i did few times before.
the problem is that it gets only the english values from the dictionary, although the host name are defined as different culture.
other things are not making the problem, for example in one of the macro i'm also getting dictionary like this:
and it takes the RIGHT dictionary values.
i looked at the umbraco.library.GetDictionary function and the language defined in the code like this:
so i guess that everything is because that the CurrentUICulture is defined as english.
maybe because my OS is in english? or maybe because my umbraco backend is in english?
i will be happy to hear ideas.
Thanks!
Eran.
anyone?..
I was looking to see if you were online to try and grab some help with the RVContactForm and here you are! :-)
Have you looked at the disassembled source for GetDictionaryItem() ?
I'm a bit too new to Umbraco to know how to set a currentUICulture, but perhaps you could extend the library and add a method which allows a culture to be passed in?
Martin
about the RVContactForm - please post a messge in the forum of the package and i will help as much as i can.
about this problem - i guess i can extend the method and send a culture, but the whole idea is that the culture will not be hardcoded, and will be dynamic, so this kind of solution may work to my specific case, but not for others. i'm trying to avoid hard-coded culture assigments.
Thanks.
Could you pull the culture from the current node using the NodeFactory perhaps?
Re the RVContactForm, it might be me, but there doesn't seem to be a package forum like there normally is against a project?
http://our.umbraco.org/projects/website-utilities/rvcontactform-multilingual-ajax-contact-form
Thanks,
Martin
this is the forum page of the RVCOntactForm Package:
http://our.umbraco.org/projects/website-utilities/rvcontactform-multilingual-ajax-contact-form/bug-reports-and-questions
maybe i can pull the culture from the current node, and then extend the umbraco source code and add culture parameter to the getDictionaryItem.
but its looks like such a common problem so i want to make sure that there is no simpler solution to that, before i'm doing that.
Good to have that forum link thanks. I'll have a read and check my questions haven't been answered before posting.
Are you using separate host names/node structures for the cultures?
Martin
yes. i defined different host names for each content tree with different culture.
Interesting to have found this earlier. I'm now suffering with the same problem as you on the RVContactForm package.
My nodes are all en-UK locale, but for some reason the call to
always looks for en-US (I've checked by outputting it into the email body).
Looking at the actual source for Umbraco, rather than the disassembled version, the function call is actually using the following:
So for some reason, the thread running on my UK machine is being forced into a US locale.
martin this is exactly my problem, maybe someone can have an idea?
I've fixed this as follows:
And in the RVContactForm class:
I guess it must be something to do with a webservice not being able to know what node and language it relates to, so having a default somewhere.
Obviously you have to amend the XSLT and .js to pass the nodeId in too..
Martin
so you extended the umbraco.library source code?
so maybe its better to send directly the current cultureID instead of the nodeID? (maybe using xslt extension)
(again, its very strange that there is no easier way to do that).
Thanks.
Eran
Exactly that, yes.
I'm not too worried about taking a shortcut for this project and you might be better off considering if there is a longer term solution. I want the NodeId to allow me to customise the email meta information depending on the node the macro is embedded in, which is why it makes a bit more sense for me to do it this way.
Martin
in that case (you want meta information from the current node) your solution sounds good.
did you test it? its working?
the only problem that i see is on future update of umbraco, the umbraco.dll will be overwrite and the package will break.
maybe we can offer the umbraco core to add this function overload to the umbraco.dll. what do you think?
Yes, all tested and working well thanks.
I'm not planning on updating this version of Umbraco for some time to come as I have had to make other tweaks also, but it would certainly be good to merge this one into the core.
Martin
so this is my conclusions and final solution:
as far as i understand, the "CurrentThread.CurrentCulture" is defined by the hostname culture that you can configure from umbraco.
the "CurrentThread.CurrentUICulture", is defined by the operation system of the user.
the function umbraco.library.GetDictionaryItem is getting the dictionary item that match to the CurrentUICulture.
this facts is the reason for my and probably yours - problem - i configure hostname as hebrew and my OS in english, so the dll alwayes bring the english dictionary items instead of the hebrew ones as expected.
so, i'd prefer not to change the umbraco.library source code (for future comptibilaty). instead, i add it as a feature request to the umbraco team.
in my package, i add at the beggining of the asmx code:
and at the end i add:
i test it and it works, so soon i will create new version of the package and upload it to the site.
Thanks,
Eran.
NOTE: in my local server its working but still problem in the live site. will update soon
the problem is solved in this post.
Thanks Martin for all the help, the solution is actually similar to your approach - in order to access the correct dictionary items from the web service, we must get the umbraco language id from the XSLT (this id is different from LCID - it comes from the umbraco table umbraco.languages).
Thanks,
Eran.
is working on a reply...