I'm not sure why it doesn't work when you've explicitely set the culture, but there's a better solution to this. If you've got a site in multiple languages, make sure to set hostnames for each of the language sites and set the appropriate culture. Doing so will make sure that each call to GetDictionaryItem("key") will get the correct translation.
If you only have a single domain, but need three different language sites and want to use the above technique for fetching the dictionary items, so your content structure looks similar to this below:
-Content --Site ---nl ---fr ---en
In this case, set a dummy hostname on the nl node (hostname: nl, culture nl-BE or nl-NL). Can do the same for fr and en node.
DictionaryItem by Culture
Hi,
I have a site in 3 languages. The Culture is set when the language changes.
e.g.
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
I've created a macro "GetCultureInfo" with the following code to check the Culture update;
When I add the macro to my template and use the language switcher, I always get the culture as expected.
But when I use a dictionary item to retrieve a translation for some static text, I only get the English value.
Any idea why the dictionary item is not taking the value based on the current culture or how to fix this?
Thanks for the help...
Chizzi,
I'm not sure why it doesn't work when you've explicitely set the culture, but there's a better solution to this. If you've got a site in multiple languages, make sure to set hostnames for each of the language sites and set the appropriate culture. Doing so will make sure that each call to GetDictionaryItem("key") will get the correct translation.
If you only have a single domain, but need three different language sites and want to use the above technique for fetching the dictionary items, so your content structure looks similar to this below:
In this case, set a dummy hostname on the nl node (hostname: nl, culture nl-BE or nl-NL). Can do the same for fr and en node.
Hope this helps.
Regards,
/Dirk
Hi Dirk,
I preferred not to work with different hostnames for this project.
But with a little trail and error, I've found that I have to set the CurrentUICulture for the dictionaryitems.
So at the language switch I set both now;
But thanks for your info anyway.
is working on a reply...