Created
May 29, 2019 12:48
-
-
Save theodesp/66e7d4f434ee1de4ef3615822fd17e6a 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
function loadCldrData(languageTag = 'en', $ = jQuery) { | |
return $.when( | |
$.get( `js/vendor/cldr/${languageTag}/ca-gregorian.json` ), | |
$.get( `js/vendor/cldr/${languageTag}/currencies.json` ), | |
$.get( `js/vendor/cldr/${languageTag}/numbers.json`), | |
$.get( `js/vendor/cldr/${languageTag}/units.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) | |
} | |
export function loadTranslationsFor(languageTag = 'en', $ = jQuery) { | |
return loadCldrData(languageTag).then(function () { | |
return $.get( `locale/${languageTag}/messages.json` ).then(function (data) { | |
return Globalize.loadMessages(data); | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment