I'm trying to use the internationalization features of Syncfusion EJ2 in Angular-Cli with WebPack, which is problematic because all the documentation uses SystemJs.
In particular I'm trying to use this sample
import { L10n, loadCldr, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
import * as currencies from './currencies.json';
import * as cagregorian from './ca-gregorian.json';
import * as numbers from './numbers.json';
import * as timeZoneNames from './timeZoneNames.json';
import * as numberingSystems from './numberingSystems.json';
import { Component, OnInit } from '@angular/core';
import { data } from './datasource';
loadCldr(currencies, cagregorian, numbers, timeZoneNames, numberingSystems);
setCulture('de-DE');
setCurrencyCode('EUR');
I tried but could not make it to work, I'm stuck on this error:
Cannot find module './numberingSystems.json'
Which changes should I make to the sample?
Webpack is a powerful module bundler which building a dependency graph, and emitting one or more bundles. With plugin and rules, Webpack can preprocess and minify different non-JavaScript files such as TypeScript, SASS, and LESS files. We can determine what Webpack does and how it does it with a JavaScript configuration file.
Getting started with Essential JS 1 for Angular with Webpack. To quick start with Syncfusion JavaScript Angular components run the below commands to clone the repository for Webpack starter and installing required dependency packages.
The cloned application already configured with ej-angular2 library to seamlessly work with Angular and Essential JavaScript components. The below steps describe, how the library consumed in the Angular seed application.
In order to import the json files in the typescript, we need to include the json type in the wildcard card module declaration( https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations ). Use the below declaration code in the typings.d.ts file to resolve the compilation issue.
declare module "*.json" {
const value: any;
export default value;
}
Note: You can also use the cldr json files by installing the npm package cldr-data. This package contains all cultures json files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With