Reputation: 1438
My Kentico 11 site's Default content culture and Visitor culture are both set to German. When I check under the settings tabs for the pages, I can see that their culture is also set to German. When I put a breakpoint in the debugger and check the value of LocalizationContext.CurrentCulture
it also returns German.
I also have the following set in web.config:
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="de-DE" uiCulture="en-US" />
However, ResHelper.GetString
only returns the english translation.
I'm guessing it's because somehow in localization module, english is still the default language:
If this is the issue how can I change this?
Update: I thought it might be related to this issue but Thread.CurrentThread.CurrentCulture
is also returning de-De
Another Update:
ResHelper.GetString("Key", CMS.Localization.LocalizationContext.CurrentCulture.CultureCode);
returns the German translation
Really good update:
Thanks to Brenden Kehren I've narrowed it down. When I call the function in a webpart like so there is no issue:
<%# CMS.Helpers.ResHelper.GetString("key") %>
But when I call it in a webservice this is where the issue comes from!
Upvotes: 0
Views: 506
Reputation: 6117
It's returning English text because you have English text in the German field. Your settings sound correct, appears to be a data entry issue based on your screenshot.
UPDATE
Based on the new screenshot and updated question, are you testing your visitor site in a new in-private window? If you have the culture in the Pages app set to English for editing and view the site in the same browser/new tab, it will show English. If you change the language in that browser on the live site, it will also update the CMS the next time it gets a full page refresh. So always test in a private browser window to eliminate the possibilities of caching or old cookies.
UPDATE 2
For this to work properly you need to access the web service in the context of a user. Meaning if a user is on the site and loads a page, the system will know what culture the user is in. Whereas if you're using it in a scheduled task, that does not run in the context of a user navigating the site, so you'd need to specify the culture in which to get the value for.
Upvotes: 1
Reputation: 838
ResHelper.GetString
works off the default UI culture, if it cannot determine a preferred culture. I'm not sure what your webservice looks like, and depending on what you're sending to it in your requests, you're most likely missing the cookies that set the culture.
Other than providing a culture code yourself:
GetString(string stringName, string culture = null, bool useDefaultCulture = true)
You might want to look at setting the default UI culture in the web.config.
The default UI culture is en-us. If you configure the system to allow more UI cultures to be used, you can change the default UI culture for users by adding the following key to the
<appSettings>
section of your site's web.config file:
<add key="CMSDefaultUICulture" value="en-nz" />
Upvotes: 1