From a86c930b9b307bb159f293a30e54515fc8d3e305 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 7 Jan 2016 09:20:00 +0100 Subject: [PATCH] fix translatations on the measures page --- .../src/main/js/apps/measures/app.js | 29 +++++++++-------- .../navigator/filters/metric-filters.js | 5 +-- .../navigator/filters/range-filters.js | 5 +-- .../templates/favorite-details-filter.hbs | 2 +- .../navigator/templates/favorite-filter.hbs | 2 +- .../navigator/templates/metric-filter.hbs | 2 +- .../navigator/templates/range-filter.hbs | 2 +- .../main/js/helpers/handlebars/translate.js | 23 ------------- .../app/views/measures/search.html.erb | 32 ------------------- 9 files changed, 25 insertions(+), 77 deletions(-) delete mode 100644 server/sonar-web/src/main/js/helpers/handlebars/translate.js diff --git a/server/sonar-web/src/main/js/apps/measures/app.js b/server/sonar-web/src/main/js/apps/measures/app.js index ebba0f44246..3e5d8986caa 100644 --- a/server/sonar-web/src/main/js/apps/measures/app.js +++ b/server/sonar-web/src/main/js/apps/measures/app.js @@ -28,16 +28,17 @@ import FavoriteFilters from '../../components/navigator/filters/favorite-filters import RangeFilters from '../../components/navigator/filters/range-filters'; import StringFilterView from '../../components/navigator/filters/string-filters'; import MetricFilterView from '../../components/navigator/filters/metric-filters'; +import { translate } from '../../helpers/l10n'; var NavigatorApp = new Marionette.Application(), newLastAnalysisFilter = function () { return new BaseFilters.Filter({ - name: window.SS.phrases.lastAnalysis, + name: translate('measure_filter.criteria.last_analysis'), propertyFrom: 'ageMinDays', propertyTo: 'ageMaxDays', type: RangeFilters.RangeFilterView, - placeholder: window.SS.phrases.days, + placeholder: translate('measure_filter.criteria.age.days'), enabled: false, optional: true }); @@ -45,7 +46,7 @@ var NavigatorApp = new Marionette.Application(), newMetricFilter = function (property) { return new BaseFilters.Filter({ - name: window.SS.phrases.metric, + name: translate('measure_filter.criteria.metric'), property: property, type: MetricFilterView, metrics: window.SS.metrics, @@ -58,7 +59,7 @@ var NavigatorApp = new Marionette.Application(), newNameFilter = function () { return new BaseFilters.Filter({ - name: window.SS.phrases.nameContains, + name: translate('measure_filter.name_contains'), property: 'nameSearch', type: StringFilterView, enabled: false, @@ -68,15 +69,15 @@ var NavigatorApp = new Marionette.Application(), newAlertFilter = function () { return new BaseFilters.Filter({ - name: window.SS.phrases.alert, + name: translate('measure_filter.criteria.alert'), property: 'alertLevels[]', type: ChoiceFilters.ChoiceFilterView, enabled: false, optional: true, choices: { - 'error': window.SS.phrases.error, - 'warn': window.SS.phrases.warning, - 'ok': window.SS.phrases.ok + 'error': translate('measure_filter.criteria.alert.error'), + 'warn': translate('measure_filter.criteria.alert.warn'), + 'ok': translate('measure_filter.criteria.alert.ok') } }); }, @@ -101,17 +102,17 @@ var NavigatorApp = new Marionette.Application(), this.filters.add([ new BaseFilters.Filter({ - name: window.SS.phrases.components, + name: translate('measure_filter.criteria.components'), property: 'qualifiers[]', type: ChoiceFilters.ChoiceFilterView, enabled: true, optional: false, choices: window.SS.qualifiers, - defaultValue: window.SS.phrases.any + defaultValue: translate('any') }), new BaseFilters.Filter({ - name: window.SS.phrases.componentsOf, + name: translate('measure_filter.criteria.components_of'), property: 'base', type: AjaxSelectFilters.ComponentFilterView, multiple: false, @@ -120,7 +121,7 @@ var NavigatorApp = new Marionette.Application(), }), new BaseFilters.Filter({ - name: window.SS.phrases.favoritesOnly, + name: translate('measure_filter.criteria.only_favorites'), property: 'onFavourites', type: CheckboxFilterView, enabled: false, @@ -128,7 +129,7 @@ var NavigatorApp = new Marionette.Application(), }), new BaseFilters.Filter({ - name: window.SS.phrases.date, + name: translate('measure_filter.criteria.date'), propertyFrom: 'fromDate', propertyTo: 'toDate', type: RangeFilters.DateRangeFilterView, @@ -137,7 +138,7 @@ var NavigatorApp = new Marionette.Application(), }), new BaseFilters.Filter({ - name: window.SS.phrases.keyContains, + name: translate('measure_filter.criteria.key_contains'), property: 'keySearch', type: StringFilterView, enabled: false, diff --git a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js index 30d070a4196..fa97b28bde3 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js @@ -21,6 +21,7 @@ import $ from 'jquery'; import _ from 'underscore'; import BaseFilters from './base-filters'; import Template from '../templates/metric-filter.hbs'; +import { translate } from '../../../helpers/l10n'; var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({ template: Template, @@ -91,7 +92,7 @@ var DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({ var value = this.model.get('value') || {}; this.$('[name=metric]').val(value.metric).select2({ width: '100%', - placeholder: window.SS.phrases.metric + placeholder: translate('measure_filter.criteria.metric') }); this.$('[name=period]').val(value.period || 0).select2({ width: '100%', @@ -153,7 +154,7 @@ export default BaseFilters.BaseFilterView.extend({ renderValue: function () { return this.isDefaultValue() ? - window.SS.phrases.notSet : + translate('measure_filter.criteria.metric.not_set') : this.model.get('value').metricText + ' ' + this.model.get('value').opText + ' ' + this.model.get('value').valText; }, diff --git a/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js index e556e6a8392..17760c4821e 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/range-filters.js @@ -21,6 +21,7 @@ import $ from 'jquery'; import _ from 'underscore'; import BaseFilters from './base-filters'; import Template from '../templates/range-filter.hbs'; +import { translate } from '../../../helpers/l10n'; var DetailsRangeFilterView = BaseFilters.DetailsFilterView.extend({ template: Template, @@ -81,7 +82,7 @@ var RangeFilterView = BaseFilters.BaseFilterView.extend({ var value = _.values(this.model.get('value')); return value.join(' — '); } else { - return window.SS.phrases.any; + return translate('any'); } }, @@ -204,7 +205,7 @@ var DateRangeFilterView = RangeFilterView.extend({ var value = _.values(this.model.get('value')); return value.join(' — '); } else { - return window.SS.phrases.anytime; + return translate('anytime') } } diff --git a/server/sonar-web/src/main/js/components/navigator/templates/favorite-details-filter.hbs b/server/sonar-web/src/main/js/components/navigator/templates/favorite-details-filter.hbs index 2af8f2fc3b5..f4c24eec9dc 100644 --- a/server/sonar-web/src/main/js/components/navigator/templates/favorite-details-filter.hbs +++ b/server/sonar-web/src/main/js/components/navigator/templates/favorite-details-filter.hbs @@ -9,6 +9,6 @@ {{/ifNotEmpty}} diff --git a/server/sonar-web/src/main/js/components/navigator/templates/favorite-filter.hbs b/server/sonar-web/src/main/js/components/navigator/templates/favorite-filter.hbs index 52e00b0692f..ee2a47af93d 100644 --- a/server/sonar-web/src/main/js/components/navigator/templates/favorite-filter.hbs +++ b/server/sonar-web/src/main/js/components/navigator/templates/favorite-filter.hbs @@ -1 +1 @@ - + diff --git a/server/sonar-web/src/main/js/components/navigator/templates/metric-filter.hbs b/server/sonar-web/src/main/js/components/navigator/templates/metric-filter.hbs index 2da85df1c86..f1c46f053e9 100644 --- a/server/sonar-web/src/main/js/components/navigator/templates/metric-filter.hbs +++ b/server/sonar-web/src/main/js/components/navigator/templates/metric-filter.hbs @@ -11,7 +11,7 @@ - + diff --git a/server/sonar-web/src/main/js/helpers/handlebars/translate.js b/server/sonar-web/src/main/js/helpers/handlebars/translate.js deleted file mode 100644 index 0414b840b5e..00000000000 --- a/server/sonar-web/src/main/js/helpers/handlebars/translate.js +++ /dev/null @@ -1,23 +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. - */ -module.exports = function () { - var args = Array.prototype.slice.call(arguments, 0, -1); - return window.translate.apply(this, args); -}; diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb index f9cedf7d9ac..fff811989ea 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/measures/search.html.erb @@ -63,38 +63,6 @@ days: '<%= message('work_duration.x_days') -%>', hours: '<%= message('work_duration.x_hours') -%>', minutes: '<%= message('work_duration.x_minutes') -%>' - }, - - phrases: { - 'any': '<%= escape_javascript message('any') -%>', - 'anytime': '<%= escape_javascript message('anytime') -%>', - 'all': '<%= escape_javascript message('all') -%>', - 'manage': '<%= escape_javascript message('manage') -%>', - 'to': '<%= escape_javascript message('to.downcase') -%>', - 'value': '<%= escape_javascript message('value') -%>', - 'components': '<%= escape_javascript message('measure_filter.criteria.components') -%>', - 'age': '<%= escape_javascript message('measure_filter.criteria.age') -%>', - 'alert': '<%= escape_javascript message('measure_filter.criteria.alert') -%>', - 'componentsOf': '<%= escape_javascript message('measure_filter.criteria.components_of') -%>', - 'date': '<%= escape_javascript message('measure_filter.criteria.date') -%>', - 'favoritesOnly': '<%= escape_javascript message('measure_filter.criteria.only_favorites') -%>', - 'keyContains': '<%= escape_javascript message('measure_filter.criteria.key_contains') -%>', - 'lastAnalysis': '<%= escape_javascript message('measure_filter.criteria.last_analysis') -%>', - 'metric': '<%= escape_javascript message('measure_filter.criteria.metric') -%>', - 'notSet': '<%= escape_javascript message('measure_filter.criteria.metric.not_set') -%>', - 'nameContains': '<%= escape_javascript message('measure_filter.name_contains') -%>', - 'moreCriteria': '<%= escape_javascript message('measure_filter.more_criteria') -%>', - 'error': '<%= escape_javascript message('measure_filter.criteria.alert.error') -%>', - 'warning': '<%= escape_javascript message('measure_filter.criteria.alert.warn') -%>', - 'ok': '<%= escape_javascript message('measure_filter.criteria.alert.ok') -%>', - 'days': '<%= escape_javascript message('measure_filter.criteria.age.days') -%>', - 'filtersList': '<%= escape_javascript message('measure_filter.filter_list') -%>', - - 'work_duration': { - 'x_days': '<%= escape_javascript message('work_duration.x_days') -%>', - 'x_hours': '<%= escape_javascript message('work_duration.x_hours') -%>', - 'x_minutes': '<%= escape_javascript message('work_duration.x_minutes') -%>' - } } }); -- 2.39.5