blob: c8d20c7fdf054aac3bf92fb9e65d0b760718501d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
// 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,
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 || this.state.availableLocales.length === 0;
}
getConfigFromState(config) {
config.LocalizationSettings.DefaultServerLocale = this.state.defaultServerLocale;
config.LocalizationSettings.DefaultClientLocale = this.state.defaultClientLocale;
config.LocalizationSettings.AvailableLocales = this.state.availableLocales.join(',');
return config;
}
getStateFromConfig(config) {
return {
defaultServerLocale: config.LocalizationSettings.DefaultServerLocale,
defaultClientLocale: config.LocalizationSettings.DefaultClientLocale,
availableLocales: config.LocalizationSettings.AvailableLocales ? config.LocalizationSettings.AvailableLocales.split(',') : []
};
}
renderTitle() {
return (
<h3>
<FormattedMessage
id='admin.general.localization'
defaultMessage='Localization'
/>
</h3>
);
}
renderSettings() {
return (
<SettingsGroup>
<DropdownSetting
id='defaultServerLocale'
values={this.state.languages}
label={
<FormattedMessage
id='admin.general.localization.serverLocaleTitle'
defaultMessage='Default Server Language:'
/>
}
value={this.state.defaultServerLocale}
onChange={this.handleChange}
helpText={
<FormattedMessage
id='admin.general.localization.serverLocaleDescription'
defaultMessage='Default language for system messages and logs. Changing this will require a server restart before taking effect.'
/>
}
/>
<DropdownSetting
id='defaultClientLocale'
values={this.state.languages}
label={
<FormattedMessage
id='admin.general.localization.clientLocaleTitle'
defaultMessage='Default Client Language:'
/>
}
value={this.state.defaultClientLocale}
onChange={this.handleChange}
helpText={
<FormattedMessage
id='admin.general.localization.clientLocaleDescription'
defaultMessage="Default language for newly created users and pages where the user hasn't logged in."
/>
}
/>
<MultiSelectSetting
id='availableLocales'
values={this.state.languages}
label={
<FormattedMessage
id='admin.general.localization.availableLocalesTitle'
defaultMessage='Available Languages:'
/>
}
selected={this.state.availableLocales}
onChange={this.handleChange}
helpText={
<FormattedMessage
id='admin.general.localization.availableLocalesDescription'
defaultMessage='Determines which languages are available for users in Account Settings. (Leave it blank to have all supported languages available)'
/>
}
noResultText={
<FormattedMessage
id='admin.general.localization.availableLocalesNoResults'
defaultMessage='No results found'
/>
}
notPresent={
<FormattedMessage
id='admin.general.localization.availableLocalesNotPresent'
defaultMessage='The default client language must be included in the available list'
/>
}
/>
</SettingsGroup>
);
}
}
|