I am working on localizing some devextreme components in my app. I decided to do this with devextreme-intl. I have an issue when I try to import messages. I wrote this:
import deMessages from 'devextreme/localization/messages/de.json';
but I get an error: Cannot find module 'devextreme/localization/messages/de.json'. I checked and this file exists in node modules, so I don't know what the issue is. I am trying to achieve something like this: https://js.devexpress.com/Demos/WidgetsGallery/Demo/Localization/UsingIntl/Angular/Light/
Using Wildcard Module Name
In your TS Definition file, e.g. typings.d.ts, you can add this line:
declare module "*.json" {
const value: any;
export default value;
}
source : https://hackernoon.com/import-json-into-typescript-8d465beded79
At first, add this to typings.d.ts:
declare module "*.json" {
const value: any;
export default value;
}
Then, import the whole json file into a string like this:
import * as deMessages from 'devextreme/localization/messages/de.json';
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