Last active
December 17, 2015 07:19
-
-
Save Maarten88/5572353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
... | |
@Html.MetaAcceptLanguage() | |
... | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundles.Add(new ScriptBundle("~/Scripts/site/js").Include( | |
"~/Scripts/jquery.validate.js", | |
"~/Scripts/jquery.validate.unobtrusive.js", | |
"~/Scripts/jquery.globalize/globalize.js", | |
"~/Scripts/jquery.globalize/cultures/globalize.culture." + System.Globalization.CultureInfo.CurrentCulture.ToString() + ".js", | |
"~/Scripts/site.js")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace Auction.Web.Utility | |
{ | |
public static class LocalizationHelper | |
{ | |
public static IHtmlString MetaAcceptLanguage(this HtmlHelper html) | |
{ | |
var acceptLang = HttpUtility.HtmlAttributeEncode(Thread.CurrentThread.CurrentUICulture.ToString()); | |
return new HtmlString(string.Format("<meta name=\"accept-language\" content=\"{0}\"/>", acceptLang)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
/* initialize globalization, for parsing dates and decimals */ | |
// Globalize.culture('%%culture%%'); | |
var data = $("meta[name='accept-language']").attr("content"); | |
Globalize.culture(data); | |
$.validator.methods.number = function (value, element) { | |
return this.optional(element) || !isNaN(Globalize.parseFloat(value)); | |
} | |
$.validator.methods.date = function (value, element) { | |
return this.optional(element) || !isNaN(Globalize.parseDate(value)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment