From 3f4d38f58ae086c6570bea7082f25cbdbc52c85d Mon Sep 17 00:00:00 2001 From: enahum Date: Wed, 15 Jun 2016 09:10:38 -0300 Subject: PLT-3344 Set Localization config to always have by default all languages available (#3339) --- config/config.json | 2 +- model/config.go | 13 +------------ webapp/components/admin_console/localization_settings.jsx | 13 +++---------- webapp/components/admin_console/multiselect_settings.jsx | 6 ++---- webapp/i18n/en.json | 2 +- webapp/i18n/es.json | 2 +- webapp/i18n/i18n.jsx | 9 +++++++-- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/config/config.json b/config/config.json index 306cf2ff8..abfbdf4af 100644 --- a/config/config.json +++ b/config/config.json @@ -163,6 +163,6 @@ "LocalizationSettings": { "DefaultServerLocale": "en", "DefaultClientLocale": "en", - "AvailableLocales": "de,en,es,fr,ja,pt-BR" + "AvailableLocales": "" } } \ No newline at end of file diff --git a/model/config.go b/model/config.go index 0afc01750..640d8d51e 100644 --- a/model/config.go +++ b/model/config.go @@ -6,7 +6,6 @@ package model import ( "encoding/json" "io" - "strings" ) const ( @@ -39,16 +38,6 @@ const ( 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 { ListenAddress string MaximumLoginAttempts int @@ -608,7 +597,7 @@ func (o *Config) SetDefaults() { if o.LocalizationSettings.AvailableLocales == nil { o.LocalizationSettings.AvailableLocales = new(string) - *o.LocalizationSettings.AvailableLocales = strings.Join(LOCALES, ",") + *o.LocalizationSettings.AvailableLocales = "" } } diff --git a/webapp/components/admin_console/localization_settings.jsx b/webapp/components/admin_console/localization_settings.jsx index 7987f77dc..67cf26fee 100644 --- a/webapp/components/admin_console/localization_settings.jsx +++ b/webapp/components/admin_console/localization_settings.jsx @@ -26,7 +26,7 @@ export default class LocalizationSettings extends AdminSettings { hasErrors: false, defaultServerLocale: props.config.LocalizationSettings.DefaultServerLocale, 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) => { return {value: locales[l].value, text: locales[l].name}; }) @@ -34,7 +34,7 @@ export default class LocalizationSettings extends AdminSettings { } 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) { @@ -112,12 +112,11 @@ export default class LocalizationSettings extends AdminSettings { /> } selected={this.state.availableLocales} - mustBePresent={this.state.defaultClientLocale} onChange={this.handleChange} helpText={ } noResultText={ @@ -126,12 +125,6 @@ export default class LocalizationSettings extends AdminSettings { defaultMessage='No results found' /> } - errorText={ - - } notPresent={ 0 && this.props.mustBePresent && values.join(',').indexOf(this.props.mustBePresent) === -1) { this.setState({error: this.props.notPresent}); } else { this.props.onChange(this.props.id, values); @@ -30,7 +28,7 @@ export default class MultiSelectSetting extends React.Component { } 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}); } else { this.setState({error: false}); diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index acc9325f9..435d25dfb 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -189,7 +189,7 @@ "admin.email.testing": "Testing...", "admin.false": "false", "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.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.", diff --git a/webapp/i18n/es.json b/webapp/i18n/es.json index 97ac41a2e..85e7de39f 100644 --- a/webapp/i18n/es.json +++ b/webapp/i18n/es.json @@ -189,7 +189,7 @@ "admin.email.testing": "Probando...", "admin.false": "falso", "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.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.", diff --git a/webapp/i18n/i18n.jsx b/webapp/i18n/i18n.jsx index 71356d75f..73838cb71 100644 --- a/webapp/i18n/i18n.jsx +++ b/webapp/i18n/i18n.jsx @@ -52,10 +52,15 @@ const languages = { let availableLanguages = null; function setAvailableLanguages() { - const available = global.window.mm_config.AvailableLocales.split(','); - + let available; availableLanguages = {}; + if (global.window.mm_config.AvailableLocales) { + available = global.window.mm_config.AvailableLocales.split(','); + } else { + available = Object.keys(languages); + } + available.forEach((l) => { if (languages[l]) { availableLanguages[l] = languages[l]; -- cgit v1.2.3-1-g7c22