VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

possible to switch language/locale at runtime? #1660

Open klokie opened 7 years ago

klokie commented 7 years ago

It's not clear to me what would be required to switch language (locale?) at runtime, e.g. by offering a menu of supported languages in the top nav bar.

It looks to me like the locale is hard-coded into the settings file – how much work would it be to adapt that to an array of supported locales? I also noticed that Telescope/Nova may have used tap-i18n, which might have provided such a solution, but no longer. Is there something similar in the works using react-intl?

Thanks for any guidance you can provide.

SachaG commented 7 years ago

The first step would be to re-enable react-intl, which is now disabled by default. After that I think it wouldn't be too hard. The part that controls the active language is the App.jsx component, so you should be able to replace that using replaceComponent.

SachaG commented 7 years ago

As for how to control the language in practice, I'd probably recommend handling that through Redux. My Redux is a bit rusty so I generally just follow this model: http://docs.vulcanjs.org/redux.html