ekoozu Posted July 20, 2019 Share Posted July 20, 2019 Hey, I'm trying to load i18next on client-side but it doesn't work, here is what i am doing: I downloaded the i18next script: https://unpkg.com/i18next/dist/umd/i18next.js Put in client_packages And trying to load like that: const i18next = require('./plugins/i18next'); // languages import en from 'lang/en'; i18next.init({ lng: 'en', resources: { en, } }); But it says i18next.init is not a function, i tried doing that with a simple node script and it worked, i know that clientside doesn't run on node, but shouldn't this work? Appreciate any help, thanks. Link to comment Share on other sites More sharing options...
TheMysteriousVincent Posted July 21, 2019 Share Posted July 21, 2019 (edited) I guess you simply do not `require` the file at all. Try appending `.js` to "i18next" Edited July 21, 2019 by TheMysteriousVincent Link to comment Share on other sites More sharing options...
ekoozu Posted July 21, 2019 Author Share Posted July 21, 2019 (edited) Hey, thanks for the reply. Appending .js doesn't seem to change anything, the file seems to be importing, because if i change the path it says `Error: could not locate file`. But for some reason on rage it doesn't seem to import the data from the file, i made this script to test (node index.js) and it works. const i18next = require('./i18next'); i18next.init({ lng: 'en', debug: false, resources: { en: { translation: { "key": "hello world" } } } }, function(err, t) { console.log(i18next.t('key')); }); This is the error RAGE returns: Maybe the way i18next is exported doesn't work on rage? Is there a way to make it work? Thanks. Edited July 21, 2019 by ekoozu Link to comment Share on other sites More sharing options...
LeonMrBonnie Posted July 26, 2019 Share Posted July 26, 2019 Clientside is only Javascript, not NodeJS. Link to comment Share on other sites More sharing options...
ekoozu Posted July 27, 2019 Author Share Posted July 27, 2019 (edited) I know, this package doesn't need node specifically. EDIT: Figured out how to do it, if anyone needs: Just use require('./i18next'); once in the client-side and it will give you the i18next variable globally. Edited July 28, 2019 by ekoozu Link to comment Share on other sites More sharing options...
Jengas Posted July 29, 2019 Share Posted July 29, 2019 Seems that you are requiring it wrong. Please check documentation Link to comment Share on other sites More sharing options...
ynhhoJ Posted July 29, 2019 Share Posted July 29, 2019 http://i18njs.com/#extensions Try that, for me it works some time ago.. Link to comment Share on other sites More sharing options...
Jengas Posted July 29, 2019 Share Posted July 29, 2019 6 минут назад, ynhhoJ сказал: http://i18njs.com/#extensions Try that, for me it works some time ago.. Yep, that's good Link to comment Share on other sites More sharing options...
ynhhoJ Posted July 29, 2019 Share Posted July 29, 2019 17 минут назад, Jengas сказал: Yep, that's good Thx! :3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now