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

What is the proper way to call i18n-2 accross main.js and renderer.js #112

Open
matejmosko opened this issue Sep 6, 2017 · 1 comment
Open

Comments

@matejmosko
Copy link

matejmosko commented Sep 6, 2017

Hello, I am struggling with the way how to properly call i18n accross whole my electron app.

Now I have this setup

main.js

const i18n = new (require('i18n-2'))({
    locales: ['en', 'sk']
});
global.i18n = i18n;
i18n.setLocaleFromEnvironmentVariable();

renderer.js

const i18n = remote.getGlobal('i18n');

Translations work as intended, even the Locale is shared. However I get strings from renderer.js detected and written in sk.js (enviroment variable) instead of en.js. Is it intended?

Thanks.

@gjuchault
Copy link
Collaborator

I'm not sure how i18n would be the cause of the locale change. Can you check what environment variables you have in main/renderer ? Maybe that comes from here.

You can also enforce language from renderer based on the language in main (something like i18n.setLocale(remote.getGlobale('locale')) (Maybe that would work).

If nothing of this helps you, can you make an example repository that I can clone ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants