jedireza / aqua

:bulb: A website and user system starter
https://jedireza.github.io/aqua/
MIT License
1.38k stars 356 forks source link

Multi language #200

Closed lukazlatecan closed 7 years ago

lukazlatecan commented 7 years ago

What is the best approach for making aqua a multi language website?

jedireza commented 7 years ago

Thanks for opening an issue. There isn't a best approach to internationalization (i18n). I suggest you do some research and find an approach that works best for your project. I haven't yet had the need for i18n in Aqua myself yet, but here are some of the first results I've found by searching:

Please update this thread with your findings.

fehrmanns commented 7 years ago

Hi there. I'm watching Aqua for while now, but didn't find time for more. :( Currently I'm working with https://github.com/yahoo/react-intl and I think it's strait forward. Okay, the documentation isn't the best but there're enough google results out there.

lukazlatecan commented 7 years ago

I managed to implement a solution with https://www.npmjs.com/package/hapi-locale-i18n. It works great and it is not so complicated to use.

lukazlatecan commented 7 years ago

However, I have problems with onClick functions when i try to change language in Navbar. Here is my function I'm trying to call: setLanguage(lang) { console.log('HERE'); i18n.setLocale(lang); }

Here is part from Navbar: <li className={this.tabClass('si')}> <a onClick={this.setLanguage.bind(this,'si')} style={{cursor: 'pointer'}}>{i18n.__("si")}</a> </li> <li className={this.tabClass('en')}> <a onClick={this.setLanguage.bind(this,'en')} style={{cursor: 'pointer'}}>{i18n.__("en")}</a> </li>

I also tried without bind, so like this: <li className={this.tabClass('si')}> <a onClick={this.setLanguage('si')} style={{cursor: 'pointer'}}>{i18n.__("si")}</a> </li> <li className={this.tabClass('en')}> <a onClick={this.setLanguage.('en')} style={{cursor: 'pointer'}}>{i18n.__("en")}</a> </li>

If you have any ideas why? Thank you

jedireza commented 7 years ago

If you had an error message it would be easier to help. But at first I'd wonder how the strings get loaded client side.