Skip to content

Instantly share code, notes, and snippets.

@theodesp
Created May 29, 2019 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodesp/14c9703c0629665a1f8a26e23bba8115 to your computer and use it in GitHub Desktop.
Save theodesp/14c9703c0629665a1f8a26e23bba8115 to your computer and use it in GitHub Desktop.
(function($) {
$.when(
$.get( 'js/vendor/cldr/en/ca-gregorian.json' ),
$.get( 'js/vendor/cldr/en/currencies.json' ),
$.get( 'js/vendor/cldr/en/numbers.json' ),
$.get( 'js/vendor/cldr/en/units.json' ),
$.get( 'js/vendor/cldr/supplemental/plurals.json' ),
$.get( 'js/vendor/cldr/supplemental/timeData.json' ),
$.get( 'js/vendor/cldr/supplemental/weekData.json' ),
$.get( 'js/vendor/cldr/supplemental/likelySubtags.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() {
const locale = new LocaleProvider(detectLocale());
locale.onChangeLocale((tag)=> {
console.log('Locale Changed to', tag);
loadTranslationsFor(tag).then(() => {
const current = Globalize(tag);
console.log(current.messageFormatter( 'like' )(10));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment