diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-01-06 16:14:25 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-01-06 16:25:12 +0100 |
commit | f4c7830570b522ad83ec9168cf12755e58192d26 (patch) | |
tree | 60cb773e73bd4cd17b5d83191897d439ea0bbad5 /server/sonar-web/src/main/js/libs | |
parent | 14fde3c0c46e717ac44a0b482f21f82149e2e837 (diff) | |
download | sonarqube-f4c7830570b522ad83ec9168cf12755e58192d26.tar.gz sonarqube-f4c7830570b522ad83ec9168cf12755e58192d26.zip |
rewrite translation module
Diffstat (limited to 'server/sonar-web/src/main/js/libs')
-rw-r--r-- | server/sonar-web/src/main/js/libs/sonar.js | 1 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/libs/translate.js | 106 |
2 files changed, 0 insertions, 107 deletions
diff --git a/server/sonar-web/src/main/js/libs/sonar.js b/server/sonar-web/src/main/js/libs/sonar.js index 670e8940290..a245d4142d4 100644 --- a/server/sonar-web/src/main/js/libs/sonar.js +++ b/server/sonar-web/src/main/js/libs/sonar.js @@ -17,7 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -require('script!./translate.js'); require('script!./third-party/jquery-ui.js'); require('script!./third-party/select2.js'); require('script!./third-party/keymaster.js'); diff --git a/server/sonar-web/src/main/js/libs/translate.js b/server/sonar-web/src/main/js/libs/translate.js deleted file mode 100644 index ddd4bc6b38f..00000000000 --- a/server/sonar-web/src/main/js/libs/translate.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube :: Web - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -(function() { - window.suppressTranslationWarnings = false; - - window.t = function() { - if (!window.messages) { - return window.translate.apply(this, arguments); - } - - var args = Array.prototype.slice.call(arguments, 0), - key = args.join('.'); - return window.messages[key] != null ? window.messages[key] : key; - }; - - window.tp = function() { - var args = Array.prototype.slice.call(arguments, 0), - key = args.shift(), - message = window.messages[key]; - if (message) { - args.forEach(function(p, i) { - message = message.replace('{' + i + '}', p); - }); - } - return message || (key + ' ' + args.join(' ')); - }; - - - window.translate = function() { - var args = Array.prototype.slice.call(arguments, 0), - tokens = args.reduce(function(prev, current) { - return prev.concat(current.split('.')); - }, []), - key = tokens.join('.'), - start = window.SS && window.SS.phrases, - found = !!start, - result = ''; - - if (found) { - result = tokens.reduce(function(prev, current) { - if (!current || !prev[current]) { - found = false; - } - return current ? prev[current] : prev; - }, start); - } - - return found ? result : key; - }; - - - window.requestMessages = function() { - var currentLocale = window.pageLang, - cachedLocale = localStorage.getItem('l10n.locale'); - if (cachedLocale !== currentLocale) { - localStorage.removeItem('l10n.timestamp'); - } - - var bundleTimestamp = localStorage.getItem('l10n.timestamp'), - params = { locale: currentLocale }; - if (bundleTimestamp !== null) { - params.ts = bundleTimestamp; - } - - var apiUrl = baseUrl + '/api/l10n/index'; - return jQuery.ajax({ - url: apiUrl, - data: params, - dataType: 'json', - statusCode: { - 304: function() { - window.messages = JSON.parse(localStorage.getItem('l10n.bundle')); - } - } - }).done(function(bundle, textStatus, jqXHR) { - if(bundle !== undefined) { - bundleTimestamp = new Date().toISOString(); - bundleTimestamp = bundleTimestamp.substr(0, bundleTimestamp.indexOf('.')) + '+0000'; - localStorage.setItem('l10n.timestamp', bundleTimestamp); - localStorage.setItem('l10n.locale', currentLocale); - - window.messages = bundle; - localStorage.setItem('l10n.bundle', JSON.stringify(bundle)); - } else if (jqXHR.status === 304) { - window.messages = JSON.parse(localStorage.getItem('l10n.bundle')); - } - }); - }; -})(); |