From 3e24b5d5a93ec570b5fb4fc452ec9d9409f0ced9 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 19 Jan 2016 14:12:38 +0100 Subject: [PATCH] fix locale generation in safari --- server/sonar-web/src/main/js/helpers/l10n.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { -- 2.39.5