Xliff file is being read but xliff.js does not allow me to create a new object

57 Views Asked by At

I have put the xliff.js file on my server in the same directory as my .html file using

In my javascript code, I have the following fetch command.

...

fetch('translations.xliff')
  .then(response => response.text())
  .then(data => console.log(data))
  .then(xliff => {
    const xliffParser = new Xliff();
    const translations = xliffParser.parse(xliff);
    // ... do something with the translations
    updateWebpage();
  });

... I know that the fetch is working because I can see the file content in the console, as expected. However, on the line "const xliffParser = new Xliff();" I getting the error message:

"caught (in promise) ReferenceError: Xliff is not defined"

Anyone have any idea why this error is showing? ChatGPT gave me this example fetch command and is now telling me that this error is occurring because "there may be a problem in the xliff.js library itself".

I find this hard to believe. I know the library itself is running (because I put an alert in the xliff.js library to prove it was there when it loaded).

0

There are 0 best solutions below