The setting of constants:

const {__, _x, _n, sprintf} = wp.i18n;

does not work in Ie11 and Safari browsers. It returns an error in the console:

Expected identifier

marking the "{" character.

Is there a way to define them that does work?

  • 1
    IE does not support const, and the {} = syntax requires Safari 8. To use these in older browsers you need to compile the code with Babel, or similar, tri create backward compatible code. Sep 12, 2019 at 8:29
  • 1
    "use strict"; var _wp$i18n = wp.i18n, __ = _wp$i18n.__, _x = _wp$i18n._x, _n = _wp$i18n._n, sprintf = _wp$i18n.sprintf; if anyone else needs it. Thank you for the tip @JacobPeattie
    – matija
    Sep 12, 2019 at 9:59


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.