kjda / ReactJs-Phonegap

A boilerplate ReactJS-Phonegap/Cordova App + Flux data flow
MIT License
261 stars 43 forks source link

Internationalization #2

Closed mschipperheyn closed 9 years ago

mschipperheyn commented 9 years ago

This is really great! One thing I would like to see is how to deal with internationalization / multilingual ui.

kjda commented 9 years ago

The App has a language store which is used to offer multilingual functionality.

you can define which languages your app supports in flux/store/lang/* if you add a new language, you have to include it in flux/store/lang/index.js

you can switch language using:

require('flux/actions/lang').setLocale('en');

For date/time localizatioins on app start you could check which locale user has, set it in AppState store One could make simple components for displaying time, dates, day names, etc according to AppState locale

it could look like this

<DateTime value={new Date()} dateOnly={true} />
<DateTime value={new Date()} timeOnly={true} /> 
<DateTime value={new Date()}  /> 

For this, I would recommend using momentjs & moment-timezone