Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devextreme-intl localization messages not found in angular 5 app

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/

like image 715
OjamaYellow Avatar asked Dec 13 '25 09:12

OjamaYellow


2 Answers

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

like image 70
Thanathip Aubdulloh Avatar answered Dec 15 '25 10:12

Thanathip Aubdulloh


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';
like image 36
slartidan Avatar answered Dec 15 '25 09:12

slartidan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!