i18next / i18next-icu

i18nFormat plugin to use ICU format with i18next
MIT License
79 stars 17 forks source link

ReferenceError: module is not defined #57

Closed ellyxc closed 1 year ago

ellyxc commented 1 year ago

šŸ› Bug Report

Using i18next-icu in browser will result ReferenceError: module is not defined error.

To Reproduce

Install i18next and i18next-icu and load in html file like below

npm install i18next i18next-icu

in the html file

<html>
<head>
  <script src="node_modules/i18next/i18next.min.js"></script>
  <script src="node_modules/i18next-icu/i18nextICU.js"></script>
</head>
<body>
  <script>
   i18next
    .use(i18nextICU)
    .init({
        lng: "en",
        resources: {
            en: {
            translation: {
                key:
                "You have {numPhotos, plural, " +
                "=0 {no photos.}" +
                "=1 {one photo.}" +
                "other {# photos.}}"
            }
            }
        }
    });
    i18next.t("key", { numPhotos: 1000 })
  </script>
</body>
</html>

Expected behavior

Javascript above run successfully, instead of returning Uncaught ReferenceError: module is not defined error.

Environment

adrai commented 1 year ago

Can you try with v2.1.0 ?

ellyxc commented 1 year ago

Can you try with v2.1.0 ?

i just tried and no error anymore. Thank you.