Aller-Couleur / handlebars-i18n

handlebars-i18next.js adds the internationalization features of i18next and Intl to handlebars.js
Other
20 stars 6 forks source link

Make dependencies peerDependencies to avoid duplicate instances #3

Closed MickL closed 3 years ago

MickL commented 3 years ago

handlebars-i18n does install its own version of handlebars, i18next and intl. When having handlebars in a project and using handlebars-i18n there are two versions of handlebars. The helpers that handlebars-i18n registers go into the instance that handlebars-i18n installed and the one actually used in the project does not have the helper.

Example:

import * as handlebars from 'handlebars';
import i18next from 'i18next';
import * as HandlebarsI18n from 'handlebars-i18n';

HandlebarsI18n.init(); // -> Registers helpers in its own instance of handlebars

i18next.init({
    resources : {
        "en" : {
            translation : {
                "phrase1": "What is good?",
            }
        },
    },
    lng : "en"
}); 
//  -> This is a different instance of i18next than the one used in handlebars-i18n

To fix that I made the dependencies a peerDependency. This also fixes the issue that handlebars-i18n may have outdated versions in its package.json which otherwise needs to be updated constantly.

I also updated the readme accordingly.

MickL commented 3 years ago

@fwalzel Seems like the tests dont run :(

github-actions[bot] commented 3 years ago

:tada: This PR is included in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: