:
Specifies the currency code to use in currency formatting.
Possible values are the ISO 4217 currency codes, such as ‘USD’ for the US dollar,‘EUR’ for the euro.
loadCldr(
require('cldr-data/main/he/numbers.json'),
require('cldr-data/main/he/currencies.json'),
require('cldr-data/supplemental/numberingSystems.json'),
require('cldr-data/supplemental/currencyData.json'),
);
L10n.load({
"he": {
"numerictextbox": {
"incrementTitle": "ערך תוספת",
"decrementTitle": "ערך הפחתה"
}
}
});
class App extends Component {
render() {
return <NumericTextBoxComponent format="c2" value={10} locale="he" currency='ILS' showSpinButton={true} />
}
} |
loadCldr(
require('cldr-data/main/ja/numbers.json'),
require('cldr-data/main/ja/currencies.json'),
require('cldr-data/supplemental/numberingSystems.json'),
require('cldr-data/supplemental/currencyData.json'),
);
L10n.load({
"ja": {
"numerictextbox": {
"incrementTitle": "増分値",
"decrementTitle": "デクリメント値"
}
}
});
class App extends Component {
render() {
return <NumericTextBoxComponent format="c2" value={10} locale="ja" currency='JPY' showSpinButton={true} />
}
} |
import { NumericTextBoxComponent } from '@syncfusion/ej2-react-inputs';
import {DropDownListComponent} from "@syncfusion/ej2-react-dropdowns";
import React, { Component } from 'react';
import { loadCldr, setCulture, Ajax } from '@syncfusion/ej2-base';
import './App.css';
setCulture("he");
loadCultureFiles('he');
var cultureData = [
{ Id: 'he', currency: 'ILS' },
{ Id: 'ja', currency: 'JPY' },
{ Id: 'fr', currency: 'EUR' }
];
var currency = "ILS";
var numericInstance;
var sharePrice = 12;
var fields = { text: 'currency', value: 'Id' };
var value = "he";
var loadedCultures = ['he'];
function onChange(args) {
if (loadedCultures.indexOf(args.value) === -1) {
loadedCultures.push(args.value);
}
setCulture(args.value);
numericInstance = document.getElementById("numeric").ej2_instances[0];
numericInstance.currency = args.itemData.currency;
}
function loadCultureFiles(name, base) {
var files = [ 'numbers.json', 'currencies.json', 'timeZoneNames.json', 'currencyData.json'];
if (name === 'en-US') {
return;
}
let loadCulture = function (prop) {
let val, ajax;
if (prop === files.length - 1) {
ajax = new Ajax("./cldr-data/supplemental/" + files[prop], "GET", true);
}
else {
ajax = new Ajax("./cldr-data/main/" + name + '/' + files[prop], "GET", true);
}
ajax.send().then(
function (value) {
val = value;
console.log(val);
loadCldr(JSON.parse(val));
},
function (reason) {
console.log(reason);
});
};
for (let prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
}
class App extends Component {
render() {
return (<div><NumericTextBoxComponent id="numeric" currency={currency} format='c4' value={sharePrice} decimals={4}
validateDecimalOnType={true} floatLabelType="Always" placeholder="Share price" width="200px"/>
<DropDownListComponent value={value} dataSource={cultureData} fields={fields} change={onChange}
floatLabelType="Always" placeholder="Currency" width="200px"/></div>);
}
}
export default App; |
export function getCurrencySymbol(currency) {
return new Intl.NumberFormat('en', {style: 'currency', currency: currency}).formatToParts("1").find(part=>part.type="currency").value;
}
If somehow this can be used inside the editor itself in future versions, let me know because there is no need to install nor define anything,
it's built in