From: Stas Vilchik Date: Tue, 19 Jan 2016 13:12:38 +0000 (+0100) Subject: fix locale generation in safari X-Git-Tag: 5.4-M9~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3e24b5d5a93ec570b5fb4fc452ec9d9409f0ced9;p=sonarqube.git fix locale generation in safari --- diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js index e61916ad72b..25c9ded9327 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.js +++ b/server/sonar-web/src/main/js/helpers/l10n.js @@ -19,6 +19,7 @@ */ import { stringify } from 'querystring'; import moment from 'moment'; +import _ from 'underscore'; let messages = {}; @@ -40,7 +41,9 @@ export function translateWithParameters (messageKey, ...parameters) { function getCurrentLocale () { const locale = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language; - return locale.replace('-', '_'); + const tags = locale.split('-'); + const [region, ...other] = tags; + return [region.toLowerCase(), ...other.map(t => t.toUpperCase())].join('_'); } function makeRequest (params) {