2

Trying to use Polyglot for the first time in my Webpack project but keep getting the error that polyglot is not defined. Can I import it from node somewhere? Or do I need to import them local?

var polyglot = new Polyglot();

polyglot.extend({
  "hello": "Hello"
});

polyglot.t("hello");
Bhoomi Patel
  • 777
  • 10
  • 32

1 Answers1

0

You have to import or require the module before using it.

import Polyglot from 'polyglot';
// const Polyglot = require('polyglot');

const polyglot = new Polyglot();

polyglot.extend({ "hello": "Hello" });

polyglot.t("hello");
kailniris
  • 8,856
  • 2
  • 17
  • 24