Jump to content
RAGE Multiplayer Community

Loading i18next on client-side


ekoozu
 Share

Recommended Posts

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

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:

d5BXDDy.jpg

Maybe the way i18next is exported doesn't work on rage? Is there a way to make it work?

 

Thanks.

Edited by ekoozu
Link to comment
Share on other sites

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 by ekoozu
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...