2

I used this post Globalize error with local numbers on .Net MVC Project to install the new version of Globalize in Asp Mvc Application.

So In the _Layout.cshtml I added this code

<script>

(function () {

    $(function () {
        $.when(
              $.getJSON("/Scripts/cldr/supplemental/likelySubtags.json"),
              $.getJSON("/Scripts/cldr/main/fr/numbers.json"),
              $.getJSON("/Scripts/cldr/supplemental/numberingSystems.json"),
              $.getJSON("/Scripts/cldr/main/fr/ca-gregorian.json"),
              $.getJSON("/Scripts/cldr/main/fr/timeZoneNames.json"),
              $.getJSON("/Scripts/cldr/supplemental/timeData.json"),
              $.getJSON("/Scripts/cldr/supplemental/weekData.json")
            ).then(function () {

                // Normalize $.get results, we only need the JSON, not the request statuses.
                return [].slice.apply(arguments, [0]).map(function (result) {
                    return result[0];
                });

            }).then(Globalize.load).then(function () {
                var culture = "fr";
                Globalize.locale(culture);
            });
    });
})();


</script>

But when i deploy in the server it doesn't work.

Ps: I added this in my web.config

<system.webServer>
...
<staticContent>
  <remove fileExtension=".json"/>
  <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

</system.webServer>

Please Help.

Community
  • 1
  • 1
Sayadi
  • 110
  • 1
  • 6

1 Answers1

0

Try this way:

$.getJSON(@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")),
$.getJSON(@Url.Content("~/Scripts/cldr/main/fr/numbers.json")),...

Might need to wrap it around in double quotes, just play around a little with the @Url.Content but I believe it will solve your problem

$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/fr/numbers.json")"),...
Denys Wessels
  • 16,829
  • 14
  • 80
  • 120
  • $.getJSON("@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")"), $.getJSON("@Url.Content("~/Scripts/cldr/main/fr/numbers.json")"),... – Sayadi Jun 05 '16 at 15:00