How to use the globalize.formatCurrency function in globalize

To help you get started, we’ve selected a few globalize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github globalizejs / globalize-compiler / test / unit / fixtures / basic.js View on Github external
// Use formatNumber.
console.log(Globalize.formatNumber(12345.6789));

// Use parseNumber.
console.log(Globalize.parseNumber("12345.6789"));

/**
 * Currency
 */

// Use currencyFormatter.
var currencyFormatter = Globalize.currencyFormatter("EUR");
console.log(currencyFormatter(9.99));

// Use formatCurrency.
console.log(Globalize.formatCurrency(69900, "USD"));

/**
 * Message
 */

// Use pluralGenerator.
var pluralGenerator = Globalize.pluralGenerator({type: "ordinal"});
console.log(pluralGenerator(2));

// Use plural.
console.log(Globalize.plural(12345.6789));

// Use messageFormatter.
like = Globalize.messageFormatter("like");
console.log(like(0));
console.log(like(1));
github globalizejs / globalize / examples / node-npm / main.js View on Github external
// Use Globalize to format dates to parts.
console.log( Globalize.formatDateToParts( new Date(), { datetime: "medium" } ) );

// Use Globalize to format numbers.
console.log( Globalize.formatNumber( 12345.6789 ) );

// Use Globalize to format numbers (compact form).
console.log( Globalize.formatNumber( 12345.6789, {
	compact: "short",
	minimumSignificantDigits: 1,
	maximumSignificantDigits: 3
}));

// Use Globalize to format currencies.
console.log( Globalize.formatCurrency( 69900, "USD" ) );

// Use Globalize to get the plural form of a numeric value.
console.log( Globalize.plural( 12345.6789 ) );

// Use Globalize to format a message with plural inflection.
like = Globalize.messageFormatter( "like" );
console.log( like( 0 ) );
console.log( like( 1 ) );
console.log( like( 2 ) );
console.log( like( 3 ) );

// Use Globalize to format relative time.
console.log( Globalize.formatRelativeTime( -35, "second" ) );

// Use Globalize to format unit.
console.log( Globalize.formatUnit( 60, "mile/hour", { form: "short" } ) );
github globalizejs / globalize / examples / node-npm / main.js View on Github external
require( "cldr-data/supplemental/timeData" ),
	require( "cldr-data/supplemental/weekData" )
);
Globalize.loadMessages( require( "./messages/en" ) );

// Set "en" as our default locale.
Globalize.locale( "en" );

// Use Globalize to format dates.
console.log( Globalize.formatDate( new Date(), { datetime: "medium" } ) );

// Use Globalize to format numbers.
console.log( Globalize.formatNumber( 12345.6789 ) );

// Use Globalize to format currencies.
console.log( Globalize.formatCurrency( 69900, "USD" ) );

// Use Globalize to get the plural form of a numeric value.
console.log( Globalize.plural( 12345.6789 ) );

// Use Globalize to format a message with plural inflection.
like = Globalize.messageFormatter( "like" );
console.log( like( 0 ) );
console.log( like( 1 ) );
console.log( like( 2 ) );
console.log( like( 3 ) );

// Use Globalize to format relative time.
console.log( Globalize.formatRelativeTime( -35, "second" ) );

// Use Globalize to format unit.
console.log( Globalize.formatUnit( 60, "mile/hour", { form: "short" } ) );