如何在页面呈现之前设置自定义区域性?
我已经为特定于客户端的语言创建了自定义文化,即我有该文化的 resx 文件。 我遇到的问题是,我似乎无法在页面周期中尽早设置文化。当我调用 Thread.CurrentThread.CurrentUICulture =culture 和 Thread.CurrentThread.CurrentCulture =culture 时,页面似乎已经从基础 resx 文件中选择了语言:( 所以我必须设置文化然后重定向回同一页面? 我已经尝试在 Page_PreInit 中设置它,但它仍然不够早?我可以参加更早的活动吗?
I have created a custom culture for client-specific language, i.e. I have resx files for that culture.
The issue I have is that I can't seem to set the culture early enough in the page cycle. By the time I call Thread.CurrentThread.CurrentUICulture = culture and Thread.CurrentThread.CurrentCulture = culture the page seems to already have picked the language from the base resx file :(
So I'm having to set the culture and then redirect back to the same page?
I've tried setting it in the Page_PreInit and its still not early enough? Is there an earlier event I can hook into?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要重写页面的InitializeCulture()方法,请查看此处 了解详情。
You need to override the page's InitializeCulture() method, look here for details.