You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
997 B

import Store from 'electron-store'
import { updateIntl } from 'react-intl-redux'
import { ipcRenderer } from 'electron'
import { translationMessages } from 'lib/utils/i18n'
// Settings store
const store = new Store({ name: 'settings' })
// ------------------------------------
// Actions
// ------------------------------------
export const setLocale = locale => (dispatch, getState) => {
const state = getState()
// Switch the active locale.
dispatch(
updateIntl({
locale,
messages: state.locale[locale]
})
)
// Save the new locale sa our language preference.
store.set('locale', locale)
// Let the main process know the locale has changed.
ipcRenderer.send('setLocale', locale)
}
export const receiveLocale = (event, locale) => dispatch => {
dispatch(setLocale(locale))
}
// ------------------------------------
// Reducer
// ------------------------------------
export default function localeReducer(state = translationMessages) {
return state
}