how-to switch resx at runtime?

半世苍凉 提交于 2019-12-01 11:26:09

问题


I have a second resx file Strings.ps-ps.resx that I want to point my code to at runtime. Each resx has Designer.cs with a unique class name. Do I have to switch/wrap these things myself? ...or is there some built in approach?


回答1:


You need to change your UI Culture to use a different resx file. This can be done in config

<globalization uiCulture="es" culture="es-MX" />

or in code

Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");;

If you want to automatically adapt to the user, you can query the HttpContext.Current.Request.UserLanguages for the users browser settings



来源:https://stackoverflow.com/questions/3479922/how-to-switch-resx-at-runtime

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