diff options
Diffstat (limited to 'app/client/system')
| -rw-r--r-- | app/client/system/system.actions.js | 5 | ||||
| -rw-r--r-- | app/client/system/system.component.js | 9 | ||||
| -rw-r--r-- | app/client/system/system.reducer.js | 17 |
3 files changed, 31 insertions, 0 deletions
diff --git a/app/client/system/system.actions.js b/app/client/system/system.actions.js index ccd9acd..73cea28 100644 --- a/app/client/system/system.actions.js +++ b/app/client/system/system.actions.js @@ -41,6 +41,11 @@ export const changeTool = (tool) => { return { type: types.app.change_tool, tool } } +export const changeLanguage = (language) => { + localStorage.setItem('cortex.i18n.language', language) + return { type: types.system.change_language, language } +} + export const enqueue_test_task = (dataset) => dispatch => { const task = { module: 'test', diff --git a/app/client/system/system.component.js b/app/client/system/system.component.js index 3783862..69a6270 100644 --- a/app/client/system/system.component.js +++ b/app/client/system/system.component.js @@ -10,6 +10,8 @@ import * as liveActions from '../live/live.actions' import * as queueActions from '../queue/queue.actions' import * as authActions from '../auth/auth.actions' +import * as i18n from '../i18n' + const cpu_test_task = { activity: 'cpu', module: 'test', @@ -122,6 +124,13 @@ class System extends Component { <button onClick={() => actions.queue.start_task(wait_test_task, { preempt: true, watch: true })}>Wait and Buzz</button> </Param> </Group> + <Group title="Internationalization"> + <Param title="Language"> + {i18n.languages.map(language => ( + <button onClick={() => actions.system.changeLanguage(language)}>{language}</button> + ))} + </Param> + </Group> </div> {this.renderCommandOutput()} </div> diff --git a/app/client/system/system.reducer.js b/app/client/system/system.reducer.js index 5f9e4ac..f232da3 100644 --- a/app/client/system/system.reducer.js +++ b/app/client/system/system.reducer.js @@ -1,7 +1,11 @@ import types from '../types' import moment from 'moment/min/moment.min' +import * as i18n from '../i18n' + let FileSaver = require('file-saver') +const initialLanguage = localStorage.getItem('cortex.i18n.language') || process.env.I18N_LANGUAGE || 'en' + const systemInitialState = { loading: false, error: null, @@ -14,6 +18,10 @@ const systemInitialState = { production: process.env.NODE_ENV === 'production', development: process.env.NODE_ENV !== 'production', }, + i18n: { + language: initialLanguage, + strings: i18n.strings(initialLanguage), + }, app: { tool: localStorage.getItem('system.last_tool') || 'pix2pixhd', }, @@ -246,6 +254,15 @@ const systemReducer = (state = systemInitialState, action) => { last_message: action.data.data, stderr: state.stderr + action.data.data, } + case types.system.change_language: + return { + ...state, + i18n: { + language: action.language, + strings: i18n.strings(action.language), + } + } + default: return state } |
