From 9e6c54651cee0fc068b6a37980b3ea1440f83f09 Mon Sep 17 00:00:00 2001 From: Pavel Date: Mon, 15 Oct 2018 13:00:17 +0300 Subject: [PATCH 01/14] translate discover plugin --- .../components/fetch_error/fetch_error.js | 21 ++- .../field_chooser/discover_field.html | 2 +- .../field_chooser/discover_field.js | 21 ++- .../field_chooser/field_chooser.html | 76 +++++---- .../components/field_chooser/field_chooser.js | 12 +- .../lib/detail_views/string.html | 35 +++- .../field_chooser/lib/field_calculator.js | 19 ++- .../public/discover/controllers/discover.js | 95 +++++++++-- .../controllers/get_painless_error.ts | 6 +- .../public/discover/directives/index.js | 5 +- .../public/discover/directives/no_results.js | 150 ++++++++++++++---- .../directives/unsupported_index_pattern.js | 13 +- .../kibana/public/discover/index.html | 49 ++++-- .../kibana/public/discover/index.js | 10 +- .../discover/saved_searches/_saved_search.js | 6 +- .../discover/top_nav/open_search_panel.js | 20 ++- 16 files changed, 414 insertions(+), 126 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js b/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js index 745693178d966..f732795f5672d 100644 --- a/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js +++ b/src/core_plugins/kibana/public/discover/components/fetch_error/fetch_error.js @@ -21,6 +21,7 @@ import 'ngreact'; import React, { Fragment } from 'react'; import { uiModules } from 'ui/modules'; import chrome from 'ui/chrome'; +import { FormattedMessage, injectI18nProvider } from '@kbn/i18n/react'; import { EuiFlexGroup, @@ -43,9 +44,21 @@ const DiscoverFetchError = ({ fetchError }) => { body = (

- You can address this error by editing the ‘{fetchError.script}’ field - in Management > Index Patterns, - under the “Scripted fields” tab. + + }} + />

); } @@ -77,4 +90,4 @@ const DiscoverFetchError = ({ fetchError }) => { const app = uiModules.get('apps/discover', ['react']); -app.directive('discoverFetchError', reactDirective => reactDirective(DiscoverFetchError)); +app.directive('discoverFetchError', reactDirective => reactDirective(injectI18nProvider(DiscoverFetchError))); diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html index 76d7bec8e454c..206239f6ae3c4 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html @@ -17,7 +17,7 @@ ng-if="field.name !== '_source'" ng-click="toggleDisplay(field)" ng-class="::field.display ? 'kuiButton--danger' : 'kuiButton--primary'" - ng-bind="::field.display ? 'remove' : 'add'" + ng-bind="::addRemoveButtonLabel" class="dscSidebarItem__action kuiButton kuiButton--small" data-test-subj="fieldToggle-{{::field.name}}" > diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js index 4627dfbdcf9e8..7472e1ff71790 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/discover_field.js @@ -26,7 +26,7 @@ import detailsHtml from './lib/detail_views/string.html'; import { uiModules } from 'ui/modules'; const app = uiModules.get('apps/discover'); -app.directive('discoverField', function ($compile) { +app.directive('discoverField', function ($compile, i18n) { return { restrict: 'E', template: html, @@ -42,11 +42,18 @@ app.directive('discoverField', function ($compile) { let detailsElem; let detailScope; - const init = function () { if ($scope.field.details) { $scope.toggleDetails($scope.field, true); } + + $scope.addRemoveButtonLabel = $scope.field.display + ? i18n('kbn.discover.fieldChooser.discoverField.removeButtonLabel', { + defaultMessage: 'remove', + }) + : i18n('kbn.discover.fieldChooser.discoverField.addButtonLabel', { + defaultMessage: 'add', + }); }; const getWarnings = function (field) { @@ -92,6 +99,16 @@ app.directive('discoverField', function ($compile) { $scope.onShowDetails(field, recompute); detailScope = $scope.$new(); detailScope.warnings = getWarnings(field); + detailScope.bucketAriaLabel = i18n('kbn.discover.fieldChooser.discoverField.bucketAriaLabel', { + defaultMessage: 'Value: {value}', + values: { + value: detailScope.bucket.display === '' + ? i18n('kbn.discover.fieldChooser.discoverField.emptyStringText', { + defaultMessage: 'Empty string', + }) + : detailScope.bucket.display, + }, + }); detailsElem = $(detailsHtml); $compile(detailsElem)(detailScope); diff --git a/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html b/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html index 2e64db6656bca..2fc2e03813180 100644 --- a/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html +++ b/src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html @@ -1,4 +1,4 @@ -