question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plurals$$1 is not a function

See original GitHub issue

I’ve just noticed an error that was previously working correctly in my setup. I’m having a hard time tracking down what is causing it.

TypeError: plurals$$1 is not a function at Object.plural (/node_modules/@lingui/core/cjs/core.development.js:101:43)

This only seems to happen when using the <Plural> macro

<Plural value={1} one="There is # message" other="There are # messages" />

My app is based off of Next.js

@lingui/react”: “2.7.2”, “@lingui/macro”: “2.7.2”, “babel-core”: “7.0.0-bridge.0”,

babelrc:

  "plugins": ["babel-plugin-idx", "macros"],
  "env": {
    "development": {
      "presets": ["next/babel"],
      "plugins": [
        [
          "babel-plugin-styled-components",
          {
            "ssr": true,
            "displayName": true,
            "preprocess": false
          }
        ]
      ]
    },
    "production": {
      "presets": ["next/babel"],
      "plugins": [
        [
          "babel-plugin-styled-components",
          {
            "ssr": true,
            "displayName": false,
            "preprocess": false
          }
        ]
      ]
    },
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]],
      "plugins": [
        [
          "babel-plugin-styled-components",
          {
            "ssr": true,
            "displayName": true,
            "preprocess": false
          }
        ]
      ]
    }
  }
}

plurals$$1 is undefined in @lingui/core/cjs/core.development.js where, when I have tested the same setup using Create React App it is a function called ‘en’, some I’m thinking I may be missing something??

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
kwassholmcommented, Aug 24, 2019

Had the same error but got rid of it when I setup the i18n with a language, i.e. :

const i18n = setupI18n({
  language: 'fi',
});
2reactions
jamiehollidaycommented, Jan 17, 2019

After a bit more investigating it looks like this is caused by setting a new instance of i18n so we could use translations outside of react as suggested in docs:

import { setupI18n } from '@lingui/core';

export const i18n = setupI18n();

<I18nProvider language="en-US" catalogs={catalogs} i18n={i18n}>

Removing the i18n prop gets rid of the the error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plurals - i18next documentation
These plurals are streamlined with the one used in the Intl API. You may need to polyfill the Intl.PluralRules API, in case it...
Read more >
Plurals not working as intended in android - Stack Overflow
A post was recently made on G+ about this. In short, it is because this will not pick the closest match by Integer...
Read more >
JavaScript: Return the singular or plural form of the word ...
Use a closure to define a function that pluralizes the given word based on the value of num. If num is either -1...
Read more >
The problem with English plurals - Word Connection
Some English plurals do not fall into any of the categories mentioned above. ... may look like plurals, but they function as singular...
Read more >
Search won't pick up plurals - WordPress.org
I am trying to help a client with their website (I am not a developer or designer!) as the search function on their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found