Globalization in JQuery is not working

戏子无情 提交于 2019-12-02 08:36:43

问题


I have been following theScott Hanselman Tutorial on Globalized Javascript Validation. It is a great tutorial wich made me understand a topic I'm not that familiar with a bit better. The only problem is that it's a bit outdated because the link he provided to files like jquery.glob.fr.js is invalid. But you get redirected to the improved version by Jquery.

That's ok, but They just don't do what they promise to do. I tried searching for tutorials and information about this, but the only help on the internet is the ReadMe file. They state this =>

Globalize.culture( "fr" );
console.log( Globalize.culture().name ) // "fr"

Globalize.culture( "fr-FR" );
console.log( Globalize.culture().name ) // "fr-FR"

But when I try it my alertbox returns en instead of nl-BE

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="../../Scripts/globalize.culture.nl.js" type="text/javascript"></script>
<script src="../../Scripts/globalize.culture.nl-BE.js" type="text/javascript"></script>
<script src="../../Scripts/modernizr-1.7.js" type="text/javascript"></script>
<script src="../../Scripts/globalize.js" type="text/javascript"></script>
@Html.MetaAcceptLanguage()
<script type="text/javascript">
    $(document).ready(function () {
        //Ask ASP.NET what culture we prefer, because we stuck it in a meta tag
        var data = $("meta[name='accept-language']").attr("content")
        //Tell jQuery to figure it out also on the client side.
        alert(data.toString());
        Globalize.culture("nl-BE");
        alert(Globalize.culture().name);
    });
</script>

At first I tried Globalize.culture(data), it didn't work so i tried nl-BE like the documentation states. No difference.

How do I get to change the culture to nl-BE instead of en?

来源:https://stackoverflow.com/questions/6750112/globalization-in-jquery-is-not-working

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