diff --git a/src/ui/public/agg_types/metrics/avg.js b/src/ui/public/agg_types/metrics/avg.js index b8e831f729857..d41a9d99ccf0c 100644 --- a/src/ui/public/agg_types/metrics/avg.js +++ b/src/ui/public/agg_types/metrics/avg.js @@ -18,12 +18,18 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const avgMetricAgg = new MetricAggType({ name: 'avg', - title: 'Average', + title: i18n.translate('common.ui.aggTypes.metrics.averageTitle', { + defaultMessage: 'Average' + }), makeLabel: function (aggConfig) { - return 'Average ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.averageLabel', { + defaultMessage: 'Average {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/bucket_avg.js b/src/ui/public/agg_types/metrics/bucket_avg.js index 408eee23c364d..72818320be120 100644 --- a/src/ui/public/agg_types/metrics/bucket_avg.js +++ b/src/ui/public/agg_types/metrics/bucket_avg.js @@ -21,11 +21,18 @@ import { get } from 'lodash'; import { MetricAggType } from './metric_agg_type'; import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; +import { i18n } from '@kbn/i18n'; + +const overallAverageLabel = i18n.translate('common.ui.aggTypes.metrics.overallAverageLabel', { + defaultMessage: 'overall average' +}); export const bucketAvgMetricAgg = new MetricAggType({ name: 'avg_bucket', - title: 'Average Bucket', - makeLabel: agg => makeNestedLabel(agg, 'overall average'), + title: i18n.translate('common.ui.aggTypes.metrics.averageBucketTitle', { + defaultMessage: 'Average Bucket' + }), + makeLabel: agg => makeNestedLabel(agg, overallAverageLabel), subtype: siblingPipelineAggHelper.subtype, params: [ ...siblingPipelineAggHelper.params() diff --git a/src/ui/public/agg_types/metrics/bucket_max.js b/src/ui/public/agg_types/metrics/bucket_max.js index aa3badc25b050..7ac63f75a820f 100644 --- a/src/ui/public/agg_types/metrics/bucket_max.js +++ b/src/ui/public/agg_types/metrics/bucket_max.js @@ -20,11 +20,18 @@ import { MetricAggType } from './metric_agg_type'; import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; +import { i18n } from '@kbn/i18n'; + +const overallMaxLabel = i18n.translate('common.ui.aggTypes.metrics.overallMaxLabel', { + defaultMessage: 'overall max' +}); export const bucketMaxMetricAgg = new MetricAggType({ name: 'max_bucket', - title: 'Max Bucket', - makeLabel: agg => makeNestedLabel(agg, 'overall max'), + title: i18n.translate('common.ui.aggTypes.metrics.maxBucketTitle', { + defaultMessage: 'Max Bucket' + }), + makeLabel: agg => makeNestedLabel(agg, overallMaxLabel), subtype: siblingPipelineAggHelper.subtype, params: [ ...siblingPipelineAggHelper.params() diff --git a/src/ui/public/agg_types/metrics/bucket_min.js b/src/ui/public/agg_types/metrics/bucket_min.js index dd2fa3e6b1638..d7ba28da7df03 100644 --- a/src/ui/public/agg_types/metrics/bucket_min.js +++ b/src/ui/public/agg_types/metrics/bucket_min.js @@ -20,11 +20,18 @@ import { MetricAggType } from './metric_agg_type'; import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; +import { i18n } from '@kbn/i18n'; + +const overallMinLabel = i18n.translate('common.ui.aggTypes.metrics.overallMinLabel', { + defaultMessage: 'overall min' +}); export const bucketMinMetricAgg = new MetricAggType({ name: 'min_bucket', - title: 'Min Bucket', - makeLabel: agg => makeNestedLabel(agg, 'overall min'), + title: i18n.translate('common.ui.aggTypes.metrics.minBucketTitle', { + defaultMessage: 'Min Bucket' + }), + makeLabel: agg => makeNestedLabel(agg, overallMinLabel), subtype: siblingPipelineAggHelper.subtype, params: [ ...siblingPipelineAggHelper.params() diff --git a/src/ui/public/agg_types/metrics/bucket_sum.js b/src/ui/public/agg_types/metrics/bucket_sum.js index 9eec111a88bb2..507d645edcc8c 100644 --- a/src/ui/public/agg_types/metrics/bucket_sum.js +++ b/src/ui/public/agg_types/metrics/bucket_sum.js @@ -20,11 +20,18 @@ import { MetricAggType } from './metric_agg_type'; import { makeNestedLabel } from './lib/make_nested_label'; import { siblingPipelineAggHelper } from './lib/sibling_pipeline_agg_helper'; +import { i18n } from '@kbn/i18n'; + +const overallSumLabel = i18n.translate('common.ui.aggTypes.metrics.overallSumLabel', { + defaultMessage: 'overall sum' +}); export const bucketSumMetricAgg = new MetricAggType({ name: 'sum_bucket', - title: 'Sum Bucket', - makeLabel: agg => makeNestedLabel(agg, 'overall sum'), + title: i18n.translate('common.ui.aggTypes.metrics.sumBucketTitle', { + defaultMessage: 'Sum Bucket' + }), + makeLabel: agg => makeNestedLabel(agg, overallSumLabel), subtype: siblingPipelineAggHelper.subtype, params: [ ...siblingPipelineAggHelper.params() diff --git a/src/ui/public/agg_types/metrics/cardinality.js b/src/ui/public/agg_types/metrics/cardinality.js index f99370e151a51..106e22a951db3 100644 --- a/src/ui/public/agg_types/metrics/cardinality.js +++ b/src/ui/public/agg_types/metrics/cardinality.js @@ -19,12 +19,18 @@ import { MetricAggType } from './metric_agg_type'; import { fieldFormats } from '../../registry/field_formats'; +import { i18n } from '@kbn/i18n'; export const cardinalityMetricAgg = new MetricAggType({ name: 'cardinality', - title: 'Unique Count', + title: i18n.translate('common.ui.aggTypes.metrics.uniqueCountTitle', { + defaultMessage: 'Unique Count' + }), makeLabel: function (aggConfig) { - return 'Unique count of ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.uniqueCountLabel', { + defaultMessage: 'Unique count of {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, getFormat: function () { return fieldFormats.getDefaultInstance('number'); diff --git a/src/ui/public/agg_types/metrics/count.js b/src/ui/public/agg_types/metrics/count.js index 6e45ce89399f3..03b2f6ed271dd 100644 --- a/src/ui/public/agg_types/metrics/count.js +++ b/src/ui/public/agg_types/metrics/count.js @@ -19,13 +19,18 @@ import { MetricAggType } from './metric_agg_type'; import { fieldFormats } from '../../registry/field_formats'; +import { i18n } from '@kbn/i18n'; export const countMetricAgg = new MetricAggType({ name: 'count', - title: 'Count', + title: i18n.translate('common.ui.aggTypes.metrics.countTitle', { + defaultMessage: 'Count' + }), hasNoDsl: true, makeLabel: function () { - return 'Count'; + return i18n.translate('common.ui.aggTypes.metrics.countLabel', { + defaultMessage: 'Count' + }); }, getFormat: function () { return fieldFormats.getDefaultInstance('number'); diff --git a/src/ui/public/agg_types/metrics/cumulative_sum.js b/src/ui/public/agg_types/metrics/cumulative_sum.js index a1e077d995a48..461c22d11f9a2 100644 --- a/src/ui/public/agg_types/metrics/cumulative_sum.js +++ b/src/ui/public/agg_types/metrics/cumulative_sum.js @@ -20,12 +20,19 @@ import { MetricAggType } from './metric_agg_type'; import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; +import { i18n } from '@kbn/i18n'; + +const cumulativeSumLabel = i18n.translate('common.ui.aggTypes.metrics.cumulativeSumLabel', { + defaultMessage: 'cumulative sum' +}); export const cumulativeSumMetricAgg = new MetricAggType({ name: 'cumulative_sum', - title: 'Cumulative Sum', + title: i18n.translate('common.ui.aggTypes.metrics.cumulativeSumTitle', { + defaultMessage: 'Cumulative Sum' + }), subtype: parentPipelineAggHelper.subtype, - makeLabel: agg => makeNestedLabel(agg, 'cumulative sum'), + makeLabel: agg => makeNestedLabel(agg, cumulativeSumLabel), params: [ ...parentPipelineAggHelper.params() ], diff --git a/src/ui/public/agg_types/metrics/derivative.js b/src/ui/public/agg_types/metrics/derivative.js index 3221b3ac192a9..5fafc9f80953f 100644 --- a/src/ui/public/agg_types/metrics/derivative.js +++ b/src/ui/public/agg_types/metrics/derivative.js @@ -20,12 +20,19 @@ import { MetricAggType } from './metric_agg_type'; import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; +import { i18n } from '@kbn/i18n'; + +const derivativeLabel = i18n.translate('common.ui.aggTypes.metrics.derivativeLabel', { + defaultMessage: 'derivative' +}); export const derivativeMetricAgg = new MetricAggType({ name: 'derivative', - title: 'Derivative', + title: i18n.translate('common.ui.aggTypes.metrics.derivativeTitle', { + defaultMessage: 'Derivative' + }), subtype: parentPipelineAggHelper.subtype, - makeLabel: agg => makeNestedLabel(agg, 'derivative'), + makeLabel: agg => makeNestedLabel(agg, derivativeLabel), params: [ ...parentPipelineAggHelper.params() ], diff --git a/src/ui/public/agg_types/metrics/geo_bounds.js b/src/ui/public/agg_types/metrics/geo_bounds.js index 5b3c2fa433a59..35d4574ff3922 100644 --- a/src/ui/public/agg_types/metrics/geo_bounds.js +++ b/src/ui/public/agg_types/metrics/geo_bounds.js @@ -18,12 +18,17 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const geoBoundsMetricAgg = new MetricAggType({ name: 'geo_bounds', - title: 'Geo Bounds', + title: i18n.translate('common.ui.aggTypes.metrics.geoBoundsTitle', { + defaultMessage: 'Geo Bounds' + }), makeLabel: function () { - return 'Geo Bounds'; + return i18n.translate('common.ui.aggTypes.metrics.geoBoundsLabel', { + defaultMessage: 'Geo Bounds' + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/geo_centroid.js b/src/ui/public/agg_types/metrics/geo_centroid.js index 74f3135ba5005..338052ea2f54f 100644 --- a/src/ui/public/agg_types/metrics/geo_centroid.js +++ b/src/ui/public/agg_types/metrics/geo_centroid.js @@ -18,12 +18,17 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const geoCentroidMetricAgg = new MetricAggType({ name: 'geo_centroid', - title: 'Geo Centroid', + title: i18n.translate('common.ui.aggTypes.metrics.geoCentroidTitle', { + defaultMessage: 'Geo Centroid' + }), makeLabel: function () { - return 'Geo Centroid'; + return i18n.translate('common.ui.aggTypes.metrics.geoCentroidLabel', { + defaultMessage: 'Geo Centroid' + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js index 610dc59309243..963d473dad876 100644 --- a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js +++ b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_controller.js @@ -19,6 +19,7 @@ import _ from 'lodash'; import { safeMakeLabel } from './safe_make_label'; +import { i18n } from '@kbn/i18n'; const parentPipelineAggController = function ($scope) { @@ -59,8 +60,11 @@ const parentPipelineAggController = function ($scope) { } else { if (lastBucket) { const type = $scope.agg.type.title; - lastBucket.error = `Last bucket aggregation must be "Date Histogram" or - "Histogram" when using "${type}" metric aggregation!`; + lastBucket.error = i18n.translate('common.ui.aggTypes.metrics.wrongLastBucketTypeErrorMessage', { + defaultMessage: 'Last bucket aggregation must be "Date Histogram" or "Histogram" when using "{type}" metric aggregation!', + values: { type }, + description: 'Date Histogram and Histogram should not be translated' + }); } } } diff --git a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.js b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.js index c54a1b8e4910d..a321836ac311b 100644 --- a/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.js +++ b/src/ui/public/agg_types/metrics/lib/parent_pipeline_agg_helper.js @@ -24,6 +24,7 @@ import { Schemas } from '../../../vis/editors/default/schemas'; import { parentPipelineAggController } from './parent_pipeline_agg_controller'; import { parentPipelineAggWriter } from './parent_pipeline_agg_writer'; import { forwardModifyAggConfigOnSearchRequestStart } from './nested_agg_helpers'; +import { i18n } from '@kbn/i18n'; const metricAggFilter = ['!top_hits', '!percentiles', '!percentile_ranks', '!median', '!std_dev']; @@ -31,14 +32,18 @@ const metricAggSchema = (new Schemas([ { group: 'none', name: 'metricAgg', - title: 'Metric Agg', + title: i18n.translate('common.ui.aggTypes.metrics.metricAggTitle', { + defaultMessage: 'Metric Agg' + }), hideCustomLabel: true, aggFilter: metricAggFilter } ])).all[0]; const parentPipelineAggHelper = { - subtype: 'Parent Pipeline Aggregations', + subtype: i18n.translate('common.ui.aggTypes.metrics.parentPipelineAggregationsSubtypeTitle', { + defaultMessage: 'Parent Pipeline Aggregations' + }), params: function () { return [ { diff --git a/src/ui/public/agg_types/metrics/lib/safe_make_label.js b/src/ui/public/agg_types/metrics/lib/safe_make_label.js index 4d5794142ed57..8c976dc236df4 100644 --- a/src/ui/public/agg_types/metrics/lib/safe_make_label.js +++ b/src/ui/public/agg_types/metrics/lib/safe_make_label.js @@ -16,11 +16,14 @@ * specific language governing permissions and limitations * under the License. */ +import { i18n } from '@kbn/i18n'; export const safeMakeLabel = function (agg) { try { return agg.makeLabel(); } catch (e) { - return '- agg not valid -'; + return i18n.translate('common.ui.aggTypes.metrics.aggNotValidErrorMessage', { + defaultMessage: '- agg not valid -' + }); } }; diff --git a/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_controller.js b/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_controller.js index 3704829fdcbb7..e4365d94df8f2 100644 --- a/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_controller.js +++ b/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_controller.js @@ -18,12 +18,19 @@ */ import { safeMakeLabel } from './safe_make_label'; +import { i18n } from '@kbn/i18n'; const siblingPipelineAggController = function (type) { return function ($scope) { + const metricTitle = i18n.translate('common.ui.aggTypes.metrics.metricTitle', { + defaultMessage: 'Metric' + }); + const bucketTitle = i18n.translate('common.ui.aggTypes.metrics.bucketTitle', { + defaultMessage: 'Bucket' + }); $scope.aggType = type; - $scope.aggTitle = type === 'customMetric' ? 'Metric' : 'Bucket'; + $scope.aggTitle = type === 'customMetric' ? metricTitle : bucketTitle; $scope.aggGroup = type === 'customMetric' ? 'metrics' : 'buckets'; $scope.safeMakeLabel = safeMakeLabel; diff --git a/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.js b/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.js index 8dc36b5e10d5e..8c926e254dce5 100644 --- a/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.js +++ b/src/ui/public/agg_types/metrics/lib/sibling_pipeline_agg_helper.js @@ -25,6 +25,7 @@ import { siblingPipelineAggController } from './sibling_pipeline_agg_controller' import { siblingPipelineAggWriter } from './sibling_pipeline_agg_writer'; import metricAggTemplate from '../../controls/sub_metric.html'; import { forwardModifyAggConfigOnSearchRequestStart } from './nested_agg_helpers'; +import { i18n } from '@kbn/i18n'; const metricAggFilter = [ '!top_hits', '!percentiles', '!percentile_ranks', '!median', '!std_dev', @@ -36,7 +37,9 @@ const metricAggSchema = (new Schemas([ { group: 'none', name: 'metricAgg', - title: 'Metric Agg', + title: i18n.translate('common.ui.aggTypes.metrics.metricAggTitle', { + defaultMessage: 'Metric Agg' + }), aggFilter: metricAggFilter } ])).all[0]; @@ -45,14 +48,18 @@ const bucketAggFilter = []; const bucketAggSchema = (new Schemas([ { group: 'none', - title: 'Bucket Agg', + title: i18n.translate('common.ui.aggTypes.metrics.bucketAggTitle', { + defaultMessage: 'Bucket Agg' + }), name: 'bucketAgg', aggFilter: bucketAggFilter } ])).all[0]; const siblingPipelineAggHelper = { - subtype: 'Sibling Pipeline Aggregations', + subtype: i18n.translate('common.ui.aggTypes.metrics.siblingPipelineAggregationsSubtypeTitle', { + defaultMessage: 'Sibling Pipeline Aggregations' + }), params: function () { return [ { diff --git a/src/ui/public/agg_types/metrics/max.js b/src/ui/public/agg_types/metrics/max.js index 1e194aa56a705..1b81bdd7b6157 100644 --- a/src/ui/public/agg_types/metrics/max.js +++ b/src/ui/public/agg_types/metrics/max.js @@ -18,12 +18,18 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const maxMetricAgg = new MetricAggType({ name: 'max', - title: 'Max', + title: i18n.translate('common.ui.aggTypes.metrics.maxTitle', { + defaultMessage: 'Max' + }), makeLabel: function (aggConfig) { - return 'Max ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.maxLabel', { + defaultMessage: 'Max {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/median.js b/src/ui/public/agg_types/metrics/median.js index f406f4711d629..849967dcd0d5e 100644 --- a/src/ui/public/agg_types/metrics/median.js +++ b/src/ui/public/agg_types/metrics/median.js @@ -19,13 +19,19 @@ import { MetricAggType } from './metric_agg_type'; import { percentilesMetricAgg } from './percentiles'; +import { i18n } from '@kbn/i18n'; export const medianMetricAgg = new MetricAggType({ name: 'median', dslName: 'percentiles', - title: 'Median', + title: i18n.translate('common.ui.aggTypes.metrics.medianTitle', { + defaultMessage: 'Median' + }), makeLabel: function (aggConfig) { - return 'Median ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.medianLabel', { + defaultMessage: 'Median {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/metric_agg_type.js b/src/ui/public/agg_types/metrics/metric_agg_type.js index f8cc2b941c99a..48d28ac345851 100644 --- a/src/ui/public/agg_types/metrics/metric_agg_type.js +++ b/src/ui/public/agg_types/metrics/metric_agg_type.js @@ -21,6 +21,7 @@ import _ from 'lodash'; import { AggType } from '../agg_type'; import { fieldFormats } from '../../registry/field_formats'; import { createLegacyClass } from '../../utils/legacy_class'; +import { i18n } from '@kbn/i18n'; createLegacyClass(MetricAggType).inherits(AggType); function MetricAggType(config) { @@ -34,7 +35,9 @@ function MetricAggType(config) { }, this); } -MetricAggType.prototype.subtype = 'Metric Aggregations'; +MetricAggType.prototype.subtype = i18n.translate('common.ui.aggTypes.metrics.metricAggregationsSubtypeTitle', { + defaultMessage: 'Metric Aggregations' +}); /** * Read the values for this metric from the * @param {[type]} bucket [description] diff --git a/src/ui/public/agg_types/metrics/min.js b/src/ui/public/agg_types/metrics/min.js index 411dcec4417c7..666f588c99e7d 100644 --- a/src/ui/public/agg_types/metrics/min.js +++ b/src/ui/public/agg_types/metrics/min.js @@ -18,12 +18,18 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const minMetricAgg = new MetricAggType({ name: 'min', - title: 'Min', + title: i18n.translate('common.ui.aggTypes.metrics.minTitle', { + defaultMessage: 'Min' + }), makeLabel: function (aggConfig) { - return 'Min ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.minLabel', { + defaultMessage: 'Min {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/moving_avg.js b/src/ui/public/agg_types/metrics/moving_avg.js index 8dbad85a21576..61b763e5e3ee7 100644 --- a/src/ui/public/agg_types/metrics/moving_avg.js +++ b/src/ui/public/agg_types/metrics/moving_avg.js @@ -20,12 +20,19 @@ import { MetricAggType } from './metric_agg_type'; import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; +import { i18n } from '@kbn/i18n'; + +const movingAvgLabel = i18n.translate('common.ui.aggTypes.metrics.movingAvgLabel', { + defaultMessage: 'moving avg' +}); export const movingAvgMetricAgg = new MetricAggType({ name: 'moving_avg', - title: 'Moving Avg', + title: i18n.translate('common.ui.aggTypes.metrics.movingAvgTitle', { + defaultMessage: 'Moving Avg' + }), subtype: parentPipelineAggHelper.subtype, - makeLabel: agg => makeNestedLabel(agg, 'moving avg'), + makeLabel: agg => makeNestedLabel(agg, movingAvgLabel), params: [ ...parentPipelineAggHelper.params() ], diff --git a/src/ui/public/agg_types/metrics/percentile_ranks.js b/src/ui/public/agg_types/metrics/percentile_ranks.js index bee3ba3d633e8..98183baf348bd 100644 --- a/src/ui/public/agg_types/metrics/percentile_ranks.js +++ b/src/ui/public/agg_types/metrics/percentile_ranks.js @@ -23,6 +23,7 @@ import { MetricAggType } from './metric_agg_type'; import { getResponseAggConfigClass } from './get_response_agg_config_class'; import { fieldFormats } from '../../registry/field_formats'; import { getPercentileValue } from './percentiles_get_value'; +import { i18n } from '@kbn/i18n'; // required by the values editor @@ -33,15 +34,23 @@ const valueProps = { const format = (field && field.format) || fieldFormats.getDefaultInstance('number'); const label = this.params.customLabel || this.getFieldDisplayName(); - return 'Percentile rank ' + format.convert(this.key, 'text') + ' of "' + label + '"'; + return i18n.translate('common.ui.aggTypes.metrics.percentileRanks.valuePropsLabel', { + defaultMessage: 'Percentile rank {format} of "{label}"', + values: { format: format.convert(this.key, 'text'), label } + }); } }; export const percentileRanksMetricAgg = new MetricAggType({ name: 'percentile_ranks', - title: 'Percentile Ranks', + title: i18n.translate('common.ui.aggTypes.metrics.percentileRanksTitle', { + defaultMessage: 'Percentile Ranks' + }), makeLabel: function (agg) { - return 'Percentile ranks of ' + agg.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.percentileRanksLabel', { + defaultMessage: 'Percentile ranks of {field}', + values: { field: agg.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/percentiles.js b/src/ui/public/agg_types/metrics/percentiles.js index bac63180577ff..76a69a03cf2f5 100644 --- a/src/ui/public/agg_types/metrics/percentiles.js +++ b/src/ui/public/agg_types/metrics/percentiles.js @@ -23,19 +23,28 @@ import '../../number_list'; import { MetricAggType } from './metric_agg_type'; import { getResponseAggConfigClass } from './get_response_agg_config_class'; import { getPercentileValue } from './percentiles_get_value'; +import { i18n } from '@kbn/i18n'; const valueProps = { makeLabel: function () { const label = this.params.customLabel || this.getFieldDisplayName(); - return ordinalSuffix(this.key) + ' percentile of ' + label; + return i18n.translate('common.ui.aggTypes.metrics.percentiles.valuePropsLabel', { + defaultMessage: '{percentile} percentile of {label}', + values: { percentile: ordinalSuffix(this.key), label } + }); } }; export const percentilesMetricAgg = new MetricAggType({ name: 'percentiles', - title: 'Percentiles', + title: i18n.translate('common.ui.aggTypes.metrics.percentilesTitle', { + defaultMessage: 'Percentiles' + }), makeLabel: function (agg) { - return 'Percentiles of ' + agg.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.percentilesLabel', { + defaultMessage: 'Percentiles of {field}', + values: { field: agg.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/serial_diff.js b/src/ui/public/agg_types/metrics/serial_diff.js index 0716d7643e4fd..52a6e2783cded 100644 --- a/src/ui/public/agg_types/metrics/serial_diff.js +++ b/src/ui/public/agg_types/metrics/serial_diff.js @@ -20,12 +20,19 @@ import { MetricAggType } from './metric_agg_type'; import { parentPipelineAggHelper } from './lib/parent_pipeline_agg_helper'; import { makeNestedLabel } from './lib/make_nested_label'; +import { i18n } from '@kbn/i18n'; + +const serialDiffLabel = i18n.translate('common.ui.aggTypes.metrics.serialDiffLabel', { + defaultMessage: 'serial diff' +}); export const serialDiffMetricAgg = new MetricAggType({ name: 'serial_diff', - title: 'Serial Diff', + title: i18n.translate('common.ui.aggTypes.metrics.serialDiffTitle', { + defaultMessage: 'Serial Diff' + }), subtype: parentPipelineAggHelper.subtype, - makeLabel: agg => makeNestedLabel(agg, 'serial diff'), + makeLabel: agg => makeNestedLabel(agg, serialDiffLabel), params: [ ...parentPipelineAggHelper.params() ], diff --git a/src/ui/public/agg_types/metrics/std_deviation.js b/src/ui/public/agg_types/metrics/std_deviation.js index c927d6b41dcd9..412eba08d6ab5 100644 --- a/src/ui/public/agg_types/metrics/std_deviation.js +++ b/src/ui/public/agg_types/metrics/std_deviation.js @@ -20,6 +20,7 @@ import _ from 'lodash'; import { MetricAggType } from './metric_agg_type'; import { getResponseAggConfigClass } from './get_response_agg_config_class'; +import { i18n } from '@kbn/i18n'; const responseAggConfigProps = { valProp: function () { @@ -32,15 +33,24 @@ const responseAggConfigProps = { return _.get(details, [this.key, 'title']); }, keyedDetails: function (customLabel, fieldDisplayName) { - const label = customLabel ? customLabel : 'Standard Deviation of ' + fieldDisplayName; + const label = customLabel ? customLabel : i18n.translate('common.ui.aggTypes.metrics.standardDeviation.keyDetailsLabel', { + defaultMessage: 'Standard Deviation of {fieldDisplayName}', + values: { fieldDisplayName } + }); return { std_lower: { valProp: ['std_deviation_bounds', 'lower'], - title: 'Lower ' + label + title: i18n.translate('common.ui.aggTypes.metrics.standardDeviation.lowerKeyDetailsTitle', { + defaultMessage: 'Lower {label}', + values: { label } + }) }, std_upper: { valProp: ['std_deviation_bounds', 'upper'], - title: 'Upper ' + label + title: i18n.translate('common.ui.aggTypes.metrics.standardDeviation.upperKeyDetailsTitle', { + defaultMessage: 'Upper {label}', + values: { label } + }) } }; } @@ -49,9 +59,14 @@ const responseAggConfigProps = { export const stdDeviationMetricAgg = new MetricAggType({ name: 'std_dev', dslName: 'extended_stats', - title: 'Standard Deviation', + title: i18n.translate('common.ui.aggTypes.metrics.standardDeviationTitle', { + defaultMessage: 'Standard Deviation' + }), makeLabel: function (agg) { - return 'Standard Deviation of ' + agg.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.standardDeviationLabel', { + defaultMessage: 'Standard Deviation of {field}', + values: { field: agg.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/sum.js b/src/ui/public/agg_types/metrics/sum.js index 82790b48de690..7c1f63f479e50 100644 --- a/src/ui/public/agg_types/metrics/sum.js +++ b/src/ui/public/agg_types/metrics/sum.js @@ -18,12 +18,18 @@ */ import { MetricAggType } from './metric_agg_type'; +import { i18n } from '@kbn/i18n'; export const sumMetricAgg = new MetricAggType({ name: 'sum', - title: 'Sum', + title: i18n.translate('common.ui.aggTypes.metrics.sumTitle', { + defaultMessage: 'Sum' + }), makeLabel: function (aggConfig) { - return 'Sum of ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.metrics.sumLabel', { + defaultMessage: 'Sum of {field}', + values: { field: aggConfig.getFieldDisplayName() } + }); }, params: [ { diff --git a/src/ui/public/agg_types/metrics/top_hit.js b/src/ui/public/agg_types/metrics/top_hit.js index e7d6b29096380..7301c2e697e57 100644 --- a/src/ui/public/agg_types/metrics/top_hit.js +++ b/src/ui/public/agg_types/metrics/top_hit.js @@ -22,6 +22,7 @@ import { MetricAggType } from './metric_agg_type'; import topSortEditor from '../controls/top_sort.html'; import aggregateAndSizeEditor from '../controls/top_aggregate_and_size.html'; import { aggTypeFieldFilters } from '../param_types/filter'; +import { i18n } from '@kbn/i18n'; const isNumber = function (type) { return type === 'number'; @@ -43,9 +44,17 @@ aggTypeFieldFilters.addFilter( export const topHitMetricAgg = new MetricAggType({ name: 'top_hits', - title: 'Top Hit', + title: i18n.translate('common.ui.aggTypes.metrics.topHitTitle', { + defaultMessage: 'Top Hit' + }), makeLabel: function (aggConfig) { - let prefix = aggConfig.params.sortOrder.val === 'desc' ? 'Last' : 'First'; + const lastPrefixLabel = i18n.translate('common.ui.aggTypes.metrics.topHit.lastPrefixLabel', { + defaultMessage: 'Last' + }); + const firstPrefixLabel = i18n.translate('common.ui.aggTypes.metrics.topHit.firstPrefixLabel', { + defaultMessage: 'First' + }); + let prefix = aggConfig.params.sortOrder.val === 'desc' ? lastPrefixLabel : firstPrefixLabel; if (aggConfig.params.size !== 1) { prefix += ` ${aggConfig.params.size}`; } @@ -85,35 +94,45 @@ export const topHitMetricAgg = new MetricAggType({ editor: aggregateAndSizeEditor, options: [ { - display: 'Min', + display: i18n.translate('common.ui.aggTypes.metrics.topHit.minLabel', { + defaultMessage: 'Min' + }), isCompatibleType: isNumber, isCompatibleVis: _.constant(true), disabled: true, val: 'min' }, { - display: 'Max', + display: i18n.translate('common.ui.aggTypes.metrics.topHit.maxLabel', { + defaultMessage: 'Max' + }), isCompatibleType: isNumber, isCompatibleVis: _.constant(true), disabled: true, val: 'max' }, { - display: 'Sum', + display: i18n.translate('common.ui.aggTypes.metrics.topHit.sumLabel', { + defaultMessage: 'Sum' + }), isCompatibleType: isNumber, isCompatibleVis: _.constant(true), disabled: true, val: 'sum' }, { - display: 'Average', + display: i18n.translate('common.ui.aggTypes.metrics.topHit.averageLabel', { + defaultMessage: 'Average' + }), isCompatibleType: isNumber, isCompatibleVis: _.constant(true), disabled: true, val: 'average' }, { - display: 'Concatenate', + display: i18n.translate('common.ui.aggTypes.metrics.topHit.concatenateLabel', { + defaultMessage: 'Concatenate' + }), isCompatibleType: _.constant(true), isCompatibleVis: function (name) { return name === 'metric' || name === 'table'; @@ -158,8 +177,18 @@ export const topHitMetricAgg = new MetricAggType({ default: 'desc', editor: topSortEditor, options: [ - { display: 'Descending', val: 'desc' }, - { display: 'Ascending', val: 'asc' } + { + display: i18n.translate('common.ui.aggTypes.metrics.topHit.descendingLabel', { + defaultMessage: 'Descending' + }), + val: 'desc' + }, + { + display: i18n.translate('common.ui.aggTypes.metrics.topHit.ascendingLabel', { + defaultMessage: 'Ascending' + }), + val: 'asc' + } ], write(agg, output) { const sortField = agg.params.sortField;