diff --git a/src/ui/public/agg_types/buckets/_interval_options.js b/src/ui/public/agg_types/buckets/_interval_options.js index 959574941dfbb..983daa0ca4335 100644 --- a/src/ui/public/agg_types/buckets/_interval_options.js +++ b/src/ui/public/agg_types/buckets/_interval_options.js @@ -16,10 +16,13 @@ * specific language governing permissions and limitations * under the License. */ +import { i18n } from '@kbn/i18n'; export const intervalOptions = [ { - display: 'Auto', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.autoDisplayName', { + defaultMessage: 'Auto', + }), val: 'auto', enabled: function (agg) { // not only do we need a time field, but the selected field needs @@ -28,39 +31,57 @@ export const intervalOptions = [ } }, { - display: 'Millisecond', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.millisecondDisplayName', { + defaultMessage: 'Millisecond', + }), val: 'ms' }, { - display: 'Second', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.secondDisplayName', { + defaultMessage: 'Second', + }), val: 's' }, { - display: 'Minute', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.minuteDisplayName', { + defaultMessage: 'Minute', + }), val: 'm' }, { - display: 'Hourly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.hourlyDisplayName', { + defaultMessage: 'Hourly', + }), val: 'h' }, { - display: 'Daily', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.dailyDisplayName', { + defaultMessage: 'Daily', + }), val: 'd' }, { - display: 'Weekly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.weeklyDisplayName', { + defaultMessage: 'Weekly', + }), val: 'w' }, { - display: 'Monthly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.monthlyDisplayName', { + defaultMessage: 'Monthly', + }), val: 'M' }, { - display: 'Yearly', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName', { + defaultMessage: 'Yearly', + }), val: 'y' }, { - display: 'Custom', + display: i18n.translate('common.ui.aggTypes.buckets.intervalOptions.customDisplayName', { + defaultMessage: 'Custom', + }), val: 'custom' } ]; diff --git a/src/ui/public/agg_types/buckets/date_histogram.js b/src/ui/public/agg_types/buckets/date_histogram.js index 78c926e9cdfcf..16e336514dc51 100644 --- a/src/ui/public/agg_types/buckets/date_histogram.js +++ b/src/ui/public/agg_types/buckets/date_histogram.js @@ -30,6 +30,7 @@ import { intervalOptions } from './_interval_options'; import intervalTemplate from '../controls/time_interval.html'; import { timefilter } from '../../timefilter'; import dropPartialTemplate from '../controls/drop_partials.html'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); const detectedTimezone = tzDetect.determine().name(); @@ -53,14 +54,22 @@ function setBounds(agg, force) { export const dateHistogramBucketAgg = new BucketAggType({ name: 'date_histogram', - title: 'Date Histogram', + title: i18n.translate('common.ui.aggTypes.buckets.dateHistogramTitle', { + defaultMessage: 'Date Histogram', + }), ordered: { date: true }, makeLabel: function (agg) { const output = this.params.write(agg); const field = agg.getFieldDisplayName(); - return field + ' per ' + (output.metricScaleText || output.bucketInterval.description); + return i18n.translate('common.ui.aggTypes.buckets.dateHistogramLabel', { + defaultMessage: '{fieldName} per {intervalDescription}', + values: { + fieldName: field, + intervalDescription: output.metricScaleText || output.bucketInterval.description, + } + }); }, createFilter: createFilterDateHistogram, decorateAggConfig: function () { diff --git a/src/ui/public/agg_types/buckets/date_range.js b/src/ui/public/agg_types/buckets/date_range.js index c197efb68ddb7..4643f7f6f9c34 100644 --- a/src/ui/public/agg_types/buckets/date_range.js +++ b/src/ui/public/agg_types/buckets/date_range.js @@ -24,10 +24,13 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterDateRange } from './create_filter/date_range'; import { fieldFormats } from '../../registry/field_formats'; import dateRangesTemplate from '../controls/date_ranges.html'; +import { i18n } from '@kbn/i18n'; export const dateRangeBucketAgg = new BucketAggType({ name: 'date_range', - title: 'Date Range', + title: i18n.translate('common.ui.aggTypes.buckets.dateRangeTitle', { + defaultMessage: 'Date Range', + }), createFilter: createFilterDateRange, getKey: function (bucket, key, agg) { const formatter = agg.fieldOwnFormatter('text', fieldFormats.getDefaultInstance('date')); diff --git a/src/ui/public/agg_types/buckets/filter.js b/src/ui/public/agg_types/buckets/filter.js index 8ac750fe36239..02b54a63ea794 100644 --- a/src/ui/public/agg_types/buckets/filter.js +++ b/src/ui/public/agg_types/buckets/filter.js @@ -18,10 +18,13 @@ */ import { BucketAggType } from './_bucket_agg_type'; +import { i18n } from '@kbn/i18n'; export const filterBucketAgg = new BucketAggType({ name: 'filter', - title: 'Filter', + title: i18n.translate('common.ui.aggTypes.buckets.filterTitle', { + defaultMessage: 'Filter', + }), params: [ { name: 'geo_bounding_box' diff --git a/src/ui/public/agg_types/buckets/filters.js b/src/ui/public/agg_types/buckets/filters.js index 381abfb86ef34..bd2071b4695d1 100644 --- a/src/ui/public/agg_types/buckets/filters.js +++ b/src/ui/public/agg_types/buckets/filters.js @@ -24,10 +24,13 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterFilters } from './create_filter/filters'; import { decorateQuery, luceneStringToDsl } from '../../courier'; import filtersTemplate from '../controls/filters.html'; +import { i18n } from '@kbn/i18n'; export const filtersBucketAgg = new BucketAggType({ name: 'filters', - title: 'Filters', + title: i18n.translate('common.ui.aggTypes.buckets.filtersTitle', { + defaultMessage: 'Filters', + }), createFilter: createFilterFilters, customLabels: false, params: [ diff --git a/src/ui/public/agg_types/buckets/geo_hash.js b/src/ui/public/agg_types/buckets/geo_hash.js index 7ec88539aad2a..a19d2d9f3010f 100644 --- a/src/ui/public/agg_types/buckets/geo_hash.js +++ b/src/ui/public/agg_types/buckets/geo_hash.js @@ -23,6 +23,7 @@ import { BucketAggType } from './_bucket_agg_type'; import precisionTemplate from '../controls/precision.html'; import { geohashColumns } from '../../utils/decode_geo_hash'; import { geoContains, scaleBounds } from '../../utils/geo_utils'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); @@ -68,7 +69,9 @@ function isOutsideCollar(bounds, collar) { export const geoHashBucketAgg = new BucketAggType({ name: 'geohash_grid', - title: 'Geohash', + title: i18n.translate('common.ui.aggTypes.buckets.geohashGridTitle', { + defaultMessage: 'Geohash', + }), params: [ { name: 'field', diff --git a/src/ui/public/agg_types/buckets/histogram.js b/src/ui/public/agg_types/buckets/histogram.js index 4e6448068f584..57498b612d8a1 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -19,7 +19,6 @@ import _ from 'lodash'; -import { i18n } from '@kbn/i18n'; import { toastNotifications } from 'ui/notify'; import '../../validate_date_interval'; import chrome from 'ui/chrome'; @@ -28,11 +27,14 @@ import { createFilterHistogram } from './create_filter/histogram'; import intervalTemplate from '../controls/number_interval.html'; import minDocCountTemplate from '../controls/min_doc_count.html'; import extendedBoundsTemplate from '../controls/extended_bounds.html'; +import { i18n } from '@kbn/i18n'; const config = chrome.getUiSettingsClient(); export const histogramBucketAgg = new BucketAggType({ name: 'histogram', - title: 'Histogram', + title: i18n.translate('common.ui.aggTypes.buckets.histogramTitle', { + defaultMessage: 'Histogram', + }), ordered: {}, makeLabel: function (aggConfig) { return aggConfig.getFieldDisplayName(); diff --git a/src/ui/public/agg_types/buckets/ip_range.js b/src/ui/public/agg_types/buckets/ip_range.js index 8e8c724c87533..e124ad69ee94a 100644 --- a/src/ui/public/agg_types/buckets/ip_range.js +++ b/src/ui/public/agg_types/buckets/ip_range.js @@ -23,10 +23,13 @@ import '../../directives/validate_cidr_mask'; import { BucketAggType } from './_bucket_agg_type'; import { createFilterIpRange } from './create_filter/ip_range'; import ipRangesTemplate from '../controls/ip_ranges.html'; +import { i18n } from '@kbn/i18n'; export const ipRangeBucketAgg = new BucketAggType({ name: 'ip_range', - title: 'IPv4 Range', + title: i18n.translate('common.ui.aggTypes.buckets.ipRangeTitle', { + defaultMessage: 'IPv4 Range', + }), createFilter: createFilterIpRange, getKey: function (bucket, key) { if (key) return key; @@ -35,7 +38,12 @@ export const ipRangeBucketAgg = new BucketAggType({ return `${from} to ${to}`; }, makeLabel: function (aggConfig) { - return aggConfig.getFieldDisplayName() + ' IP ranges'; + return i18n.translate('common.ui.aggTypes.buckets.ipRangeLabel', { + defaultMessage: '{fieldName} IP ranges', + values: { + fieldName: aggConfig.getFieldDisplayName() + } + }); }, params: [ { diff --git a/src/ui/public/agg_types/buckets/range.js b/src/ui/public/agg_types/buckets/range.js index d51e315084bc8..20d0de4b4f02d 100644 --- a/src/ui/public/agg_types/buckets/range.js +++ b/src/ui/public/agg_types/buckets/range.js @@ -22,16 +22,24 @@ import { createFilterRange } from './create_filter/range'; import { FieldFormat } from '../../../field_formats/field_format'; import { RangeKey } from './range_key'; import rangesTemplate from '../controls/ranges.html'; +import { i18n } from '@kbn/i18n'; const keyCaches = new WeakMap(); const formats = new WeakMap(); export const rangeBucketAgg = new BucketAggType({ name: 'range', - title: 'Range', + title: i18n.translate('common.ui.aggTypes.buckets.rangeTitle', { + defaultMessage: 'Range', + }), createFilter: createFilterRange, makeLabel: function (aggConfig) { - return aggConfig.getFieldDisplayName() + ' ranges'; + return i18n.translate('common.ui.aggTypes.buckets.rangesLabel', { + defaultMessage: '{fieldName} ranges', + values: { + fieldName: aggConfig.getFieldDisplayName() + } + }); }, getKey: function (bucket, key, agg) { let keys = keyCaches.get(agg); @@ -57,7 +65,13 @@ export const rangeBucketAgg = new BucketAggType({ const RangeFormat = FieldFormat.from(function (range) { const format = agg.fieldOwnFormatter(); - return `${format(range.gte)} to ${format(range.lt)}`; + return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { + defaultMessage: '{from} to {to}', + values: { + from: format(range.gte), + to: format(range.lt) + } + }); }); format = new RangeFormat(); diff --git a/src/ui/public/agg_types/buckets/significant_terms.js b/src/ui/public/agg_types/buckets/significant_terms.js index 544a85123cc0d..77e8a0f80a506 100644 --- a/src/ui/public/agg_types/buckets/significant_terms.js +++ b/src/ui/public/agg_types/buckets/significant_terms.js @@ -20,12 +20,21 @@ import { BucketAggType } from './_bucket_agg_type'; import { createFilterTerms } from './create_filter/terms'; import orderAndSizeTemplate from '../controls/order_and_size.html'; +import { i18n } from '@kbn/i18n'; export const significantTermsBucketAgg = new BucketAggType({ name: 'significant_terms', - title: 'Significant Terms', + title: i18n.translate('common.ui.aggTypes.buckets.significantTermsTitle', { + defaultMessage: 'Significant Terms', + }), makeLabel: function (aggConfig) { - return 'Top ' + aggConfig.params.size + ' unusual terms in ' + aggConfig.getFieldDisplayName(); + return i18n.translate('common.ui.aggTypes.buckets.significantTermsLabel', { + defaultMessage: 'Top {size} unusual terms in {fieldName}', + values: { + size: aggConfig.params.size, + fieldName: aggConfig.getFieldDisplayName(), + } + }); }, createFilter: createFilterTerms, params: [ diff --git a/src/ui/public/agg_types/buckets/terms.js b/src/ui/public/agg_types/buckets/terms.js index 8f5301bdb64c1..0427fbf435447 100644 --- a/src/ui/public/agg_types/buckets/terms.js +++ b/src/ui/public/agg_types/buckets/terms.js @@ -26,6 +26,7 @@ import { createFilterTerms } from './create_filter/terms'; import orderAggTemplate from '../controls/order_agg.html'; import orderAndSizeTemplate from '../controls/order_and_size.html'; import otherBucketTemplate from '../controls/other_bucket.html'; +import { i18n } from '@kbn/i18n'; import { getRequestInspectorStats, getResponseInspectorStats } from '../../courier/utils/courier_inspector_utils'; import { buildOtherBucketAgg, mergeOtherBucketAggResponse, updateMissingBucket } from './_terms_other_bucket_helper'; @@ -40,7 +41,9 @@ const orderAggSchema = (new Schemas([ { group: 'none', name: 'orderAgg', - title: 'Order Agg', + title: i18n.translate('common.ui.aggTypes.buckets.terms.orderAggTitle', { + defaultMessage: 'Order Agg', + }), hideCustomLabel: true, aggFilter: aggFilter } @@ -70,7 +73,9 @@ const migrateIncludeExcludeFormat = { export const termsBucketAgg = new BucketAggType({ name: 'terms', - title: 'Terms', + title: i18n.translate('common.ui.aggTypes.buckets.termsTitle', { + defaultMessage: 'Terms', + }), makeLabel: function (agg) { const params = agg.params; return agg.getFieldDisplayName() + ': ' + params.order.display; @@ -254,8 +259,18 @@ export const termsBucketAgg = new BucketAggType({ default: 'desc', editor: orderAndSizeTemplate, options: [ - { display: 'Descending', val: 'desc' }, - { display: 'Ascending', val: 'asc' } + { + display: i18n.translate('common.ui.aggTypes.buckets.terms.orderDescendingTitle', { + defaultMessage: 'Descending', + }), + val: 'desc' + }, + { + display: i18n.translate('common.ui.aggTypes.buckets.terms.orderAscendingTitle', { + defaultMessage: 'Ascending', + }), + val: 'asc' + } ], write: _.noop // prevent default write, it's handled by orderAgg }, @@ -270,7 +285,9 @@ export const termsBucketAgg = new BucketAggType({ write: _.noop }, { name: 'otherBucketLabel', - default: 'Other', + default: i18n.translate('common.ui.aggTypes.buckets.terms.otherBucketLabel', { + defaultMessage: 'Other', + }), write: _.noop }, { name: 'missingBucket', @@ -278,7 +295,9 @@ export const termsBucketAgg = new BucketAggType({ write: _.noop }, { name: 'missingBucketLabel', - default: 'Missing', + default: i18n.translate('common.ui.aggTypes.buckets.terms.missingBucketLabel', { + defaultMessage: 'Missing', + }), write: _.noop }, { diff --git a/src/ui/public/agg_types/param_types/field.js b/src/ui/public/agg_types/param_types/field.js index 8fd330d1d1eff..38eaa75d43ec9 100644 --- a/src/ui/public/agg_types/param_types/field.js +++ b/src/ui/public/agg_types/param_types/field.js @@ -26,6 +26,7 @@ import { IndexedArray } from '../../indexed_array'; import { toastNotifications } from '../../notify'; import { createLegacyClass } from '../../utils/legacy_class'; import { propFilter } from '../../filters/_prop_filter'; +import { i18n } from '@kbn/i18n'; const filterByType = propFilter('type'); @@ -67,7 +68,14 @@ FieldParamType.prototype.deserialize = function (fieldName, aggConfig) { const validField = this.getAvailableFields(aggConfig.getIndexPattern().fields).byName[fieldName]; if (!validField) { - toastNotifications.addDanger(`Saved "field" parameter is now invalid. Please select a new field.`); + toastNotifications.addDanger( + i18n.translate('common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage', { + defaultMessage: 'Saved {fieldParameter} parameter is now invalid. Please select a new field.', + values: { + fieldParameter: '"field"' + } + }) + ); } return validField; @@ -112,7 +120,14 @@ FieldParamType.prototype.write = function (aggConfig, output) { const field = aggConfig.getField(); if (!field) { - throw new TypeError('"field" is a required parameter'); + throw new TypeError( + i18n.translate('common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage', { + defaultMessage: '{fieldParameter} is a required parameter', + values: { + fieldParameter: '"field"' + } + }) + ); } if (field.scripted) {