Aller-Couleur / handlebars-i18n

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

Example with npm install doesn't work #34

Closed Diferno closed 2 years ago

Diferno commented 2 years ago

Hi!

Have been using your module for currency and numbers for a while. Now I need to i18n text and... found that always returns undefined. Grabbed the example in your code, and also got undefineds where the text should appear. Is it a version related?

This is the output I get when running the example code using the modules installed from npm using this versions: package.json

    "handlebars": "^4.7.7",
    "handlebars-i18n": "^1.3.1",
    "i18next": "^21.6.11",
    "intl": "^1.2.5",
EXAMPLE OUTPUT:
------------------------
undefined
undefined
undefined
undefined
undefined
undefined 
Deutsch 
7,000.00
3
33.333
€9,999.99
¥1,001
DKK12.99
2/18/2022
3/11/2020
3/11/2020
12/20/2012
2/18/22
3/11/2020
3/11/2020
3/11/2020
3/11/2020

This is the output running the same example but requiring the handlebars-i18n.js that is in your dist folder of the example.


EXAMPLE OUTPUT:
------------------------
Was ist gut?
handlebars-i18n ist gut.
1 Gegenstand
7 Gegenstand
Was ist gut?
Die ausgewählte Sprache ist: de
Deutsch 
7.000,00
3
33,333
9.999,99 €
1.001 ¥
12,99 DKK
18.2.2022, 9:33
11.3.2020, 3:24
11.3.2020, 11:35
20.12.2012, 3:00
18.02.22
11.3.2020, 3:24
2020
11.3.2020
3:24:00
fwalzel commented 2 years ago

Hi,

thanks for reporting the issue. This is somewhat strange, i don't know what exactly causes the problem, but for the moment I have a work around for you. If you use the examples/browser-example/simple-example.js outside the original handlebars-i18n folder you need to require i18next

in line 16 like this:

const i18next = require('./node_modules/handlebars-i18n/node_modules/i18next/index');

instead of:

const i18next = require('i18next');

Should work for the moment. I try to fix the dependency tree as soon as I have the time to fully investigate the problem. Cheers!

fwalzel commented 2 years ago

Okay, here it comes. Since npm version >= 7 peer Depenedencies are installed differently.

If you use npm >= 7 do: $ npm i handlebars-i18n

For older versions do: $ npm i handlebars-i18n handlebars@4.7.6 i18next@20.2.1 intl@1.2.5

This resolves the issue. I fixed in in the readme.md. Thanks for noticing the problem !

rubeonline commented 2 years ago

Hi i have the same issue. Im using npm 7.10.0 and installed it via npm i handlebars-i18n

When im running your example following error appears:

Error: Cannot find module '../../dist/handlebars-i18n.js'

My package.json looks like: { "name": "handlebars-i18n", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "node index.js" }, "author": "", "license": "ISC", "dependencies": { "handlebars-i18n": "^1.4.0" } }

fwalzel commented 2 years ago

Have you tried installing via $ npm i handlebars-i18n handlebars@4.7.6 i18next@20.2.1 intl@1.2.5 ?

rubeonline commented 2 years ago

Yes. Also with npm 7.10.0. Then this appears:


npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: handlebars-i18n@1.0.0
npm ERR! Found: handlebars@4.7.6
npm ERR! node_modules/handlebars
npm ERR!   handlebars@"4.7.6" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer handlebars@"^4.7.7" from handlebars-i18n@1.4.0
npm ERR! node_modules/handlebars-i18n
npm ERR!   handlebars-i18n@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/sergejrube/.npm/eresolve-report.txt for a full report.
fwalzel commented 2 years ago

Okay, I will try to reproduce your error. Gimme some time, please.