如何本地化 ASP.NET MVC 应用程序中的控制器名称和操作? [英] How to localize the Controller names and actions in an ASP.NET MVC application?

查看:26
本文介绍了如何本地化 ASP.NET MVC 应用程序中的控制器名称和操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想完全本地化我的 ASP.NET MVC 应用程序,虽然有很多文章涉及 ASP.NET MVC 本地化的各种陷阱,但没有一篇涉及我想要处理的方面,这就是 URL 的本地化,包括控制器名称和操作.

我想要一种方法来指定应该出现的字符串,而不是 URL 中的控制器名称和操作名称,例如在资源文件中.

如何以一种理智的方式做到这一点?预先感谢您的帮助!


我仍在寻找一种方法来做到这一点.欢迎任何帮助.
是否有任何框架或库已经实现了这一点?

解决方案

我以前从未这样做过,但是您不能为要支持的每种语言在路由表中添加一个条目吗?所有本地化路线都可以重定向到您选择的语言的路线.查看这些相关问题:

使用 ASP.NET MVC 的多语言网站>

我应该如何使用 ASP.NET 实现本地化MVC 路由?

I'd like to fully localize my ASP.NET MVC application, and while there are many articles that deal with the various pitfalls of ASP.NET MVC localization, none of them deals with an aspect that I want to deal with, and that is the localization of URLs, including the controller names and actions.

I would like a way to specify the strings that should appear instead of the controller name and action name in the URL, for example in a resource file.

How is this doable in a sane way? Thanks in advance for your help!

EDIT:
I'm still looking for a way to do this. Any help would be welcome.
Is there any framework or lib implementing this already?

解决方案

I've never done this before, but couldn't you add an entry to the routes table for every language you want to support? All of the localized routes could redirect to the route in the language of your choice. Check out these related questions:

Multi-lingual websites with ASP.NET MVC

How should I implement localization with ASP.NET MVC routes?

这篇关于如何本地化 ASP.NET MVC 应用程序中的控制器名称和操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆