使用 .resx 文件本地化后,如何使客户能够以其语言查看整个网站?
我的大多数 .resx 文件都位于 App_GlobalResources(显式)中,母版页位于其目录的 App_LocalResources 中(隐式)。我必须将所有页面的顶行设置为culture / uiculture - auto。
现在我的语言已经设置完毕,Nuux 向我解释了如何创建下拉框并翻译该特定页面,这太棒了——比我拥有的要多得多。
但是,如果我希望最终用户在主页上看到一组标志,以便他们可以手动选择以该语言查看整个网站,该怎么办?这比我已经做过的复杂得多,还是只是复制和粘贴?是否需要为每种语言创建一个目录?任何建议或指导将不胜感激!
Most of my .resx files are in App_GlobalResources (explicit), and the master pages are in the App_LocalResources in their directories (implicit). I have to top line in all my pages set to culture / uiculture - auto.
Now that my languages are set up, Nuux explained to me how to create a drop-down box and translate that particular page, and this is great -- a lot more than I had.
But what if I want the end-user to see an array of flags on the homepage, so they can manually opt to view the entire site in that language? Is this a LOT more intricate than what I've already done, or is it just copying and pasting? Is it going to involve creating a directory for each language? Any suggestions or guidance would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这段代码开发具有 MasterPage 和本地化的 ASP.NET 页面。让它适合您的需要。如果您无法自定义它。我会尽力帮助你。
更新:好的,让我们试试这个:
将新类添加到您的项目:并用此覆盖其内容
现在转到您拥有的每个页面的代码隐藏并更改 Inherits 子句:
之后,您需要在母版页中实现语言接口母版页
代码隐藏文件中的事件仍然是:
现在您的网站已准备就绪,只需根据您的喜好自定义我使用的控件即可。
剩下的事情是,我们使用 Session 来存储用户选择,但是,当会话过期时,会向用户显示默认语言,因此您可以用持久 cookie 替换 Session。首先让这个想法发挥作用,希望改成cookie不会有问题。我只是希望你牢记这个概念。
Take a look at this code Developing an ASP.NET page with MasterPage and Localization. Make it fit your need. If you couldn't customize it. I'll try to help you.
Update: Ok, let us try this:
Add new class to your project: and overwrite its content with this
Now go to the codebehind of every page you have and change the Inherits clause :
After this point you need to implement the language interface in a master page
The event in the masterpage codebehind file remains:
Now your website is ready only customize the control I used to your preference.
On thing remaining is that we used Session to store the user selection, however, when the session expires the user is presented with the default language so you may replace the Session with a persistent cookie. First let this idea work, I hope changing to cookie won't be a problem. I just wanted you keep this concept in mind.