PLT-3344 Set Localization config to always have by default all languages available (#3339)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
c7e9f3cb1b
Коммит
3f4d38f58a
@@ -163,6 +163,6 @@
|
|||||||
"LocalizationSettings": {
|
"LocalizationSettings": {
|
||||||
"DefaultServerLocale": "en",
|
"DefaultServerLocale": "en",
|
||||||
"DefaultClientLocale": "en",
|
"DefaultClientLocale": "en",
|
||||||
"AvailableLocales": "de,en,es,fr,ja,pt-BR"
|
"AvailableLocales": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@ package model
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -39,16 +38,6 @@ const (
|
|||||||
RESTRICT_EMOJI_CREATION_ADMIN = "system_admin"
|
RESTRICT_EMOJI_CREATION_ADMIN = "system_admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// should match the values in webapp/i18n/i18n.jsx
|
|
||||||
var LOCALES = []string{
|
|
||||||
"de",
|
|
||||||
"en",
|
|
||||||
"es",
|
|
||||||
"fr",
|
|
||||||
"ja",
|
|
||||||
"pt-BR",
|
|
||||||
}
|
|
||||||
|
|
||||||
type ServiceSettings struct {
|
type ServiceSettings struct {
|
||||||
ListenAddress string
|
ListenAddress string
|
||||||
MaximumLoginAttempts int
|
MaximumLoginAttempts int
|
||||||
@@ -608,7 +597,7 @@ func (o *Config) SetDefaults() {
|
|||||||
|
|
||||||
if o.LocalizationSettings.AvailableLocales == nil {
|
if o.LocalizationSettings.AvailableLocales == nil {
|
||||||
o.LocalizationSettings.AvailableLocales = new(string)
|
o.LocalizationSettings.AvailableLocales = new(string)
|
||||||
*o.LocalizationSettings.AvailableLocales = strings.Join(LOCALES, ",")
|
*o.LocalizationSettings.AvailableLocales = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default class LocalizationSettings extends AdminSettings {
|
|||||||
hasErrors: false,
|
hasErrors: false,
|
||||||
defaultServerLocale: props.config.LocalizationSettings.DefaultServerLocale,
|
defaultServerLocale: props.config.LocalizationSettings.DefaultServerLocale,
|
||||||
defaultClientLocale: props.config.LocalizationSettings.DefaultClientLocale,
|
defaultClientLocale: props.config.LocalizationSettings.DefaultClientLocale,
|
||||||
availableLocales: props.config.LocalizationSettings.AvailableLocales.split(','),
|
availableLocales: props.config.LocalizationSettings.AvailableLocales ? props.config.LocalizationSettings.AvailableLocales.split(',') : [],
|
||||||
languages: Object.keys(locales).map((l) => {
|
languages: Object.keys(locales).map((l) => {
|
||||||
return {value: locales[l].value, text: locales[l].name};
|
return {value: locales[l].value, text: locales[l].name};
|
||||||
})
|
})
|
||||||
@@ -34,7 +34,7 @@ export default class LocalizationSettings extends AdminSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canSave() {
|
canSave() {
|
||||||
return this.state.availableLocales.join(',').indexOf(this.state.defaultClientLocale) !== -1;
|
return this.state.availableLocales.join(',').indexOf(this.state.defaultClientLocale) !== -1 || this.state.availableLocales.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfigFromState(config) {
|
getConfigFromState(config) {
|
||||||
@@ -112,12 +112,11 @@ export default class LocalizationSettings extends AdminSettings {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
selected={this.state.availableLocales}
|
selected={this.state.availableLocales}
|
||||||
mustBePresent={this.state.defaultClientLocale}
|
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
helpText={
|
helpText={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.general.localization.availableLocalesDescription'
|
id='admin.general.localization.availableLocalesDescription'
|
||||||
defaultMessage='Determines which languages are available for users in Account Settings.'
|
defaultMessage='Determines which languages are available for users in Account Settings. (Leave it blank to have all supported languages available)'
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
noResultText={
|
noResultText={
|
||||||
@@ -126,12 +125,6 @@ export default class LocalizationSettings extends AdminSettings {
|
|||||||
defaultMessage='No results found'
|
defaultMessage='No results found'
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
errorText={
|
|
||||||
<FormattedMessage
|
|
||||||
id='admin.general.localization.availableLocalesError'
|
|
||||||
defaultMessage='There has to be at least one language available'
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
notPresent={
|
notPresent={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='admin.general.localization.availableLocalesNotPresent'
|
id='admin.general.localization.availableLocalesNotPresent'
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ export default class MultiSelectSetting extends React.Component {
|
|||||||
return n.value;
|
return n.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!newValue || newValue.length === 0) {
|
if (this.props.selected.length > 0 && this.props.mustBePresent && values.join(',').indexOf(this.props.mustBePresent) === -1) {
|
||||||
this.setState({error: this.props.errorText});
|
|
||||||
} else if (this.props.mustBePresent && values.join(',').indexOf(this.props.mustBePresent) === -1) {
|
|
||||||
this.setState({error: this.props.notPresent});
|
this.setState({error: this.props.notPresent});
|
||||||
} else {
|
} else {
|
||||||
this.props.onChange(this.props.id, values);
|
this.props.onChange(this.props.id, values);
|
||||||
@@ -30,7 +28,7 @@ export default class MultiSelectSetting extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(newProps) {
|
componentWillReceiveProps(newProps) {
|
||||||
if (newProps.mustBePresent && newProps.selected.join(',').indexOf(newProps.mustBePresent) === -1) {
|
if (newProps.selected.length > 0 && newProps.mustBePresent && newProps.selected.join(',').indexOf(newProps.mustBePresent) === -1) {
|
||||||
this.setState({error: this.props.notPresent});
|
this.setState({error: this.props.notPresent});
|
||||||
} else {
|
} else {
|
||||||
this.setState({error: false});
|
this.setState({error: false});
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
"admin.email.testing": "Testing...",
|
"admin.email.testing": "Testing...",
|
||||||
"admin.false": "false",
|
"admin.false": "false",
|
||||||
"admin.general.localization": "Localization",
|
"admin.general.localization": "Localization",
|
||||||
"admin.general.localization.availableLocalesDescription": "Determines which languages are available for users in Account Settings.",
|
"admin.general.localization.availableLocalesDescription": "Determines which languages are available for users in Account Settings. (Leave it blank to have all supported languages available)",
|
||||||
"admin.general.localization.clientLocaleDescription": "Default language for newly created users and pages where the user hasn't logged in.",
|
"admin.general.localization.clientLocaleDescription": "Default language for newly created users and pages where the user hasn't logged in.",
|
||||||
"admin.general.localization.serverLocaleDescription": "Default language for system messages and logs. Changing this will require a server restart before taking effect.",
|
"admin.general.localization.serverLocaleDescription": "Default language for system messages and logs. Changing this will require a server restart before taking effect.",
|
||||||
"admin.gitab.clientSecretDescription": "Obtain this value via the instructions above for logging into GitLab.",
|
"admin.gitab.clientSecretDescription": "Obtain this value via the instructions above for logging into GitLab.",
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
"admin.email.testing": "Probando...",
|
"admin.email.testing": "Probando...",
|
||||||
"admin.false": "falso",
|
"admin.false": "falso",
|
||||||
"admin.general.localization": "Idiomas",
|
"admin.general.localization": "Idiomas",
|
||||||
"admin.general.localization.availableLocalesDescription": "Determina qué idiomas están disponibles para los usuarios en la Configuración de la Cuenta.",
|
"admin.general.localization.availableLocalesDescription": "Determina qué idiomas están disponibles para los usuarios en la Configuración de la Cuenta. (al dejarlo en blanco se tienen disponibles todos los idiomas soportados.",
|
||||||
"admin.general.localization.clientLocaleDescription": "Idioma predeterminado para nuevos usuarios y páginas donde el usuario no ha iniciado sesión.",
|
"admin.general.localization.clientLocaleDescription": "Idioma predeterminado para nuevos usuarios y páginas donde el usuario no ha iniciado sesión.",
|
||||||
"admin.general.localization.serverLocaleDescription": "Idioma predeterminado para los mensajes del sistema y los registros. Cambiar esto requerirá un reinicio del servidor antes de tomar efecto.",
|
"admin.general.localization.serverLocaleDescription": "Idioma predeterminado para los mensajes del sistema y los registros. Cambiar esto requerirá un reinicio del servidor antes de tomar efecto.",
|
||||||
"admin.gitab.clientSecretDescription": "Utilizar este valor vía instrucciones suministradas anteriormente para iniciar sesión en GitLab.",
|
"admin.gitab.clientSecretDescription": "Utilizar este valor vía instrucciones suministradas anteriormente para iniciar sesión en GitLab.",
|
||||||
|
|||||||
@@ -52,10 +52,15 @@ const languages = {
|
|||||||
let availableLanguages = null;
|
let availableLanguages = null;
|
||||||
|
|
||||||
function setAvailableLanguages() {
|
function setAvailableLanguages() {
|
||||||
const available = global.window.mm_config.AvailableLocales.split(',');
|
let available;
|
||||||
|
|
||||||
availableLanguages = {};
|
availableLanguages = {};
|
||||||
|
|
||||||
|
if (global.window.mm_config.AvailableLocales) {
|
||||||
|
available = global.window.mm_config.AvailableLocales.split(',');
|
||||||
|
} else {
|
||||||
|
available = Object.keys(languages);
|
||||||
|
}
|
||||||
|
|
||||||
available.forEach((l) => {
|
available.forEach((l) => {
|
||||||
if (languages[l]) {
|
if (languages[l]) {
|
||||||
availableLanguages[l] = languages[l];
|
availableLanguages[l] = languages[l];
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user