Format Numbers and Currencies Based on the English-India Locale Parameter
The following sample formats numbers and currencies based on the English-India (en_IN) locale parameter.
Note:
This sample script uses the require
function so that you can copy it into the SuiteScript Debugger and test it. You must use the define
function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.
/**
* @NApiVersion 2.x
*/
require(['N/format/i18n'], function(format) {
var curFormatter = format.getCurrencyFormatter({
locale: "en_IN"
});
var curCur = curFormatter.currency; // curCur is 'INR'
var numberFormat = curFormatter.numberFormatter;
var sym = curFormatter.symbol; // sym is '₹'
var gs = numberFormat.groupSeparator; // gs is ','
var ds = numberFormat.decimalSeparator; // ds is '.'
var prec = numberFormat.precision; // prec is 2
var nnf = numberFormat.negativeNumberFormat; // nnf is MINUS
var currency1 = curFormatter.format({
number: 12345678.55
}); // currency1 is '₹1,23,45,678.55'
var currency2 = curFormatter.format({
number: -345678.55
}); // currency2 is '₹-3,45,678.55'
});