JavaScript中的CultureInfo [英] CultureInfo in JavaScript

查看:72
本文介绍了JavaScript中的CultureInfo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中我使用下面的方法来获取CultureInfo。

In c# I use the below method in order to get the CultureInfo.

System.Globalization.CultureInfo.CurrentCulture.Name // output :en-US

任何人都可以告诉我如何在JavaScript中获取CultureInfo?

Can any one tell me how can I get the CultureInfo in JavaScript?

推荐答案

非常简单的方法是将其渲染到视图中,如下所示:

Very easy way is to render it into the view, like this:

<script>
  var cultureInfo = '@System.Globalization.CultureInfo.CurrentCulture.Name';
</script>

这是剃刀语法,如果你使用经典的asp.net,那么使用:

This is razor syntax, if you use classic asp.net, then use:

<script>
  var cultureInfo = '<%= System.Globalization.CultureInfo.CurrentCulture.Name %>';
</script>

这篇关于JavaScript中的CultureInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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