Using `ResHelper` to get resource string uses thread culture not LocalizationContext

試著忘記壹切 提交于 2020-01-05 07:28:16

问题


Using Kentico CMS with a multi culture site, we have custom code to get a resource string, when we use ResHelper.GetString("someKey") it does not use LocalizationContext.CurrentCulture version of the string, it is always defaulting to the US culture.

When I pass in the culture code to use as the second parameter using Localization.CurrentCulture.CultureCode it returns the correct string?

Using a quick watch and breakpoint at the code, I can see that Thread.CurrentThread.CurrentCulture and CurrentUICulture are both set to US whilst LocalizationContext.CurrentCulture is set to which ever version of the website we are viewing.

Why wouldn't Kentico set the Thread culture if resource strings rely on it?

We have used many resource strings throughout the site, some are using built in cms controls <cms:LocalizedLabel ResourceString="someKey" /> - how do these controls work?

Thanks

来源:https://stackoverflow.com/questions/42813808/using-reshelper-to-get-resource-string-uses-thread-culture-not-localizationcon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!