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.

Cannot import default instance of I18n

See original GitHub issue

The documentation states :

lingui-i18n still exports the default instance of I18n class, this remains unchanged: import i18n from 'lingui-i18n'

But if I try to import it in my tests I get the warning:

"export 'default' (imported as 'i18n') was not found in 'lingui-i18n'

Same if I try to import the instance in the application itself.

Importing setupI18n works as expected.

import { setupI18n } from 'lingui-i18n';

const i18n = setupI18n();

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tricoder42commented, Jul 12, 2017

Closing, unfortunately this is common caveat when mixing named and default exports.

I’ve added named i18n export and recommend use it to avoid confusion. Default export will be removed in 2.0.

// ES
import { i18n } from 'lingui-i18n'

// CommonJS
const i18n = require('lingui-i18n').i18n
0reactions
tricoder42commented, Jul 11, 2017

I was thinking about dropping this default export completely, so we get rid of one global object, but that’s another topic. I’ll check if there’s nothing we can do about mixing default and named exports.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import i18n in Vue file - Stack Overflow
If you'd like use vue-i18n, in your main.js you should import vue-i18n library first and create an i18n variable like this:
Read more >
i18n-js - npm
First, you need to instantiate I18n with the translations' object, the main class of this library. import { I18n } from "i18n-js"; ...
Read more >
How to properly internationalize a React application using ...
pass the i18n instance to react-i18next. .use(initReactI18next) ... );export default Footer;// imported in our App.js and used like this // <Footer t={t} />....
Read more >
Translation | Django documentation
Defaults to None , which means that all available translations from all INSTALLED_APPS are provided in the JavaScript output. Example with default values:...
Read more >
A Guide to React Localization with i18next | Phrase
To finish our setup, we just need to import our initialized i18next instance into our index.js file. This ensures that the file is...
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