From 159953050a9c4fb700bbde79042ead4843b0bea5 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 2 Jun 2016 16:47:26 -0300 Subject: PLT-1800 Load server side locale from the config.json (#3202) * PLT-1800 Load server side locale from the config.json * Add support for locales with country specifics * Fix localization on served locale file as plain/text * Remove github.com/cloudfoundry/jibber_jabber as vendor dependency * Fix get locale on login_controller --- .../admin_console/localization_settings.jsx | 145 +++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 webapp/components/admin_console/localization_settings.jsx (limited to 'webapp/components/admin_console/localization_settings.jsx') diff --git a/webapp/components/admin_console/localization_settings.jsx b/webapp/components/admin_console/localization_settings.jsx new file mode 100644 index 000000000..6876e0c36 --- /dev/null +++ b/webapp/components/admin_console/localization_settings.jsx @@ -0,0 +1,145 @@ +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import * as I18n from 'i18n/i18n.jsx'; + +import AdminSettings from './admin_settings.jsx'; +import {FormattedMessage} from 'react-intl'; +import SettingsGroup from './settings_group.jsx'; +import DropdownSetting from './dropdown_setting.jsx'; +import MultiSelectSetting from './multiselect_settings.jsx'; + +export default class LocalizationSettings extends AdminSettings { + constructor(props) { + super(props); + + this.getConfigFromState = this.getConfigFromState.bind(this); + + this.renderSettings = this.renderSettings.bind(this); + this.canSave = this.canSave.bind(this); + + const locales = I18n.getAllLanguages(); + + this.state = Object.assign(this.state, { + hasErrors: false, + defaultServerLocale: props.config.LocalizationSettings.DefaultServerLocale, + defaultClientLocale: props.config.LocalizationSettings.DefaultClientLocale, + availableLocales: props.config.LocalizationSettings.AvailableLocales.split(','), + languages: Object.keys(locales).map((l) => { + return {value: locales[l].value, text: locales[l].name}; + }) + }); + } + + canSave() { + return this.state.availableLocales.join(',').indexOf(this.state.defaultClientLocale) !== -1; + } + + getConfigFromState(config) { + config.LocalizationSettings.DefaultServerLocale = this.state.defaultServerLocale; + config.LocalizationSettings.DefaultClientLocale = this.state.defaultClientLocale; + config.LocalizationSettings.AvailableLocales = this.state.availableLocales.join(','); + + return config; + } + + renderTitle() { + return ( +

+ +

+ ); + } + + renderSettings() { + return ( + + } + > + + } + value={this.state.defaultServerLocale} + onChange={this.handleChange} + helpText={ + + } + /> + + } + value={this.state.defaultClientLocale} + onChange={this.handleChange} + helpText={ + + } + /> + + } + selected={this.state.availableLocales} + mustBePresent={this.state.defaultClientLocale} + onChange={this.handleChange} + helpText={ + + } + noResultText={ + + } + errorText={ + + } + notPresent={ + + } + /> + + ); + } +} \ No newline at end of file -- cgit v1.2.3-1-g7c22