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.

Multi instance of i18n

See original GitHub issue

When the module is used in a project and the project has a module which use i18n module too, there are automatically some conflicts because the require function return Singleton…

It could be fun to add a function to create multiple instances of the module like this fork. https://www.npmjs.com/package/i18n-factory

Why do not integrate this feature in the official package?

Regards,

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ieugencommented, Jan 8, 2019

I found this issue that offers an alternative: - merge the json files as part of a build process . However, I find this practice sub-optimal for my case since when I have to update the translations I have a build step instead of a simple copy step.

I also have to duplicate / maintain this step inside the repo and maybe as a prodcution binary. There are solutions to this but why do that when a simple copy would work ok - if i18n has support for returning new objects instead of the singleton - which should be easy to do IMO.

1reaction
mashpiecommented, Aug 16, 2020

now… feature is released as of 0.12.0 with some extra sugar (shortcut to i18n.configure on creation):

const { I18n } = require("i18n");

const i18n = new I18n({
    locales:['en', 'de'],
    directory: __dirname + '/locales'
});

see https://github.com/mashpie/i18n-node/tree/master#as-instance for details

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to have multiple instances of i18next for component library
How to have multiple instances of i18next for component library · Step 1: create i18next instance · Step 2: I18nextProvider.
Read more >
Unable to have multiple i18next instances (React apps) on the ...
I have a page which contains 2 React apps, each having their own i18n.js config file like the one below. The last app...
Read more >
i18next-react - how to have 2 instances of i18next in the same ...
I develop a component npm library that use 18next. the consumer of the library, also use 18next. we created instance for each and...
Read more >
i18next instance
The instance is an initialized i18next instance. In the following code snippet, ... import i18n from 'i18next'; ... Multiple Translation Files.
Read more >
I18n-support-multi-instance NPM | npm.io
Lightweight simple translation module with dynamic json storage. Supports plain vanilla node.js apps and should work with any framework (like express, restify ...
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