diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-06-04 13:52:16 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-06-06 20:20:50 +0200 |
commit | 434c61ad74dc6ddeeb21477a8754064db95b4b5c (patch) | |
tree | 2f2e582dd222f7183c4f3a6040a142d02a2f0b29 /server | |
parent | 20dbd44984a97b58745ddd363614c33f86339f37 (diff) | |
download | sonarqube-434c61ad74dc6ddeeb21477a8754064db95b4b5c.tar.gz sonarqube-434c61ad74dc6ddeeb21477a8754064db95b4b5c.zip |
SONAR-10841 Correctly set default language bundle when locale is unknown
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-web/src/main/js/app/components/LocalizationContainer.tsx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/app/components/LocalizationContainer.tsx b/server/sonar-web/src/main/js/app/components/LocalizationContainer.tsx index aea9b8490ac..22c457bf7ea 100644 --- a/server/sonar-web/src/main/js/app/components/LocalizationContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/LocalizationContainer.tsx @@ -47,15 +47,20 @@ export default class LocalizationContainer extends React.PureComponent<Props, St bundleLoaded = (lang: string) => { const langToLoad = lang || DEFAULT_LANGUAGE; - - // No need to load english bundle, it's coming wiht react-intl, use english if it fails - if (langToLoad !== 'en') { + // No need to load english (default) bundle, it's coming with react-intl + if (langToLoad !== DEFAULT_LANGUAGE) { import('react-intl/locale-data/' + langToLoad).then( - i => this.updateLang(langToLoad, i), - () => {} + intlBundle => this.updateLang(langToLoad, intlBundle), + this.setDefaultLang ); } else { - this.setState({ loading: false, lang: langToLoad }); + this.setDefaultLang(); + } + }; + + setDefaultLang = () => { + if (this.mounted) { + this.setState({ loading: false, lang: DEFAULT_LANGUAGE }); } }; |