4

Globalize.js を使用する ASP MVC アプリケーションを開発しています。_Layout.cshtml にこのコードを追加しました

<script>
(function () {
$(function () {
    $.when(
              $.getJSON("@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")"),
              $.getJSON("@Url.Content("~/Scripts/cldr/main/fr/numbers.json")"),
              $.getJSON("@Url.Content("~/Scripts/cldr/supplemental/numberingSystems.json")"),
              $.getJSON("@Url.Content("~/Scripts/cldr/main/fr/ca-gregorian.json")"),
              $.getJSON("@Url.Content("~/Scripts/cldr/main/fr/timeZoneNames.json")"),
              $.getJSON("@Url.Content("~/Scripts/cldr/supplemental/timeData.json")"),
              $.getJSON("@Url.Content("~/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 () {
                Globalize.locale("fr");
            });
});
})();
</script>

それは働いています。しかし、$(document).ready または $(window).load の他のページで使用しようとすると、エラー JavaScript: E_DEFAULT_LOCALE_NOT_DEFINED: Default locale has not been defined が発生します。

グローバル化がまだロードされていないようです。

4

2 に答える 2