在 JQuery 中获取本地化语言
我通过使用以下格式的 URL 在我的网站中显示和确定所选语言:
/{languageCode}/Area/Controller/Action
在我的 C# 中,当我需要查找语言代码时,我使用此语法:
RouteData.Values["languageCode"]
但是,当我需要使用 JQuery 调用操作时,如何做我确定语言代码,以便可以调用正确的路线,即 en-US/Area/Controller/Action
?我不知道如何在客户端 Javascript 中访问此信息。有人可以帮忙吗?
I am displaying and determining the selected language in my website by using URLs in this format :
/{languageCode}/Area/Controller/Action
And in my C# when I need to find the language Code I am using this syntax :
RouteData.Values["languageCode"]
However, when I need to call an action using JQuery, how do I determine the language code so that I can call the correct route i.e. en-US/Area/Controller/Action
? I don't know how to access this information in my client side Javascript. Can anybody help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为您的 URL 有语言代码。如何使用
https://developer.mozilla.org/en/DOM/window.location< /a>
然后从 url 中提取语言。也许是这样的:
不需要使用 JQuery! :)
Since your URL has the language code. How about using
https://developer.mozilla.org/en/DOM/window.location
And then extract the language from the url. Maybe something like:
No need to use JQuery! :)
您可以在服务器端发出它,例如:
You could emit it, server-side, e.g.: