Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#437 - Move execution for IIFE to index.js #438

Closed
wants to merge 2 commits into from

Conversation

woodcockjosh
Copy link

By moving the execution of the IIFE to index.js it allows me to bypass the globally created instance of i18n in order to preserve the context between applications.

This change allows me to import i18n function like this

const i18nFn = require('i18n/i18n');

const i18nInstance = new i18nFn();

i18nInstance.configure({});

Which is a solution for #437

rather than

const i18n = require('i18n');

i18n.configure({});

So that the subsequent calls to configure do not overwrite the preceding calls to configure

@coveralls
Copy link

coveralls commented Jul 20, 2020

Coverage Status

Coverage increased (+0.004%) to 97.778% when pulling 9674bc2 on woodcockjosh:master into fb9aa22 on mashpie:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-96.6%) to 1.215% when pulling 3c9979d on woodcockjosh:master into fb9aa22 on mashpie:master.

@woodcockjosh
Copy link
Author

Possible dupe of #329

@mashpie
Copy link
Owner

mashpie commented Aug 16, 2020

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

@mashpie mashpie closed this Aug 16, 2020
@mashpie mashpie moved this from To do to Done in loader, factory, constructor, class Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants