Select to view content in your preferred language

intl fetchMessageBundle cannot find JSON loader

945
1
03-24-2021 07:17 AM
MichailMarinakis1
Frequent Contributor

Hi all, 

in the new JS API version 4.18, we are using the new way to translate custom widgets by using the new decorator in the tsx files e.g. 

@messageBundle("gis/commonMessages")
Most of the times it is working, including multiple JSON files with different names but some times when we destroy the widget and recreate it, it cannot find the loader.
 
In other cases we cannot use this decorator and we need to use the method fetchMessageBundle to get our messages. So we do something like this 
await intl.fetchMessageBundle("gis/widgetMessages").then((messagesany)  => {})
 
In both use cases, the JSON is accessible from the site, and the JSONloader is correctly loaded, but we receive the error message there is no loader for these messages. 
 
We try to debug a bit, and there is a weird behavior with a regex query when it tries to find the loader. The first time it tries to find the loader it returns false, the second it returns true, the third it returns false the fourth true etc etc.
 
We suspect it is a bug, ooor we are doing something wrong 😁
 
Please let us know about any feedback!
0 Kudos
1 Reply
MichailMarinakis1
Frequent Contributor

We found the issue... 

we copied the example found here and we discovered that the regex variable patternBundle is wrong. We removed the ending /g, so the variable is not a global one any more. That's it!

0 Kudos