globalizejs / globalizejs/globalize

formatDate is not a function or E_MISSING_BUNDLE: {"locale":"en"}

Open
#634 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

I am in the phase of thrashing around in an attempt to get things to do something...anything. So far, I am not having a lot of luck.

**If I initialize utilizing .locale("en"), I receive a E_MISSING_BUNDLE: {"locale":"en"} error.

If I initialize without and just go with Globalize("en"), I receive formatDate is not a function.**

I have looked at numerous posts, examples, etc. and have been unable to find a resolution thus far. I know I am missing something but I don't know what.

`
$(document).ready(function() {

```
$('#btn-translate')
.click(function(e) {

var selectedLocale = $('#CultureSelect').val();
//alert($('#CultureSelect').val());

initGlobalization(selectedLocale);

//$('#inp-translated-number').val("Translated number");
//$('#inp-translated-message').val("Translated message");
});

function initGlobalization(selectedLocale) {

// alert("Selected locale " + selectedLocale);

// Use $.getJSON instead of $.get if your server is not configured to return the
// right MIME type for .json files.
$.when(
$.get("Scripts/i18n/globalize-1.1.1/cldr/main/en/ca-generic.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/main/en/timeZoneNames.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/supplemental/timeData.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/supplemental/weekData.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/main/en/numbers.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/supplemental/numberingSystems.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/supplemental/likelySubtags.json"),
$.get("Scripts/i18n/globalize-1.1.1/cldr/supplemental/timeData.json"),
$.get("Scripts/i18n/globalize-1.1.1/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).done(function () {

// Your code goes here.

var globalize = Globalize("en");

var globalizedDate = globalize.formatDate(new Date(), { datetime: "medium" });

$('#inp-translated-datetime').val(globalizedDate);

});
}
```

});
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.