Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover translations #24079

Merged
merged 24 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9e6c546
translate discover plugin
pavel06081991 Oct 15, 2018
035e1aa
Translate Discover Component
tibmt Oct 16, 2018
a80f58a
update discover translation PR
tibmt Oct 22, 2018
eaf9147
Update fetch_error.js
tibmt Oct 22, 2018
5925e54
Merge branch 'master' into feature/discover-translations
tibmt Oct 23, 2018
5416832
Merge branch 'master' into feature/discover-translations
tibmt Oct 24, 2018
ca2af5e
Merge branch 'master' into feature/discover-translations
maryia-lapata Nov 1, 2018
2fba3f3
Update unit tests
maryia-lapata Nov 1, 2018
9567b07
Fix eslint
maryia-lapata Nov 2, 2018
e953eac
Merge branch 'master' into feature/discover-translations
pavel06081991 Nov 5, 2018
af732e3
use separate span tag for label
pavel06081991 Nov 5, 2018
0b0fb6a
use separate tags for translated labels
pavel06081991 Nov 5, 2018
0aac7fb
resolve review comments
pavel06081991 Nov 5, 2018
809286a
Update snapshot
maryia-lapata Nov 6, 2018
25c0b4c
fix issue with bucket aria-label
pavel06081991 Nov 8, 2018
b1ffeae
Merge branch 'feature/discover-translations' of github.com:tibmt/kiba…
pavel06081991 Nov 8, 2018
526efd0
Merge branch 'master' into feature/discover-translations
pavel06081991 Nov 8, 2018
8f04388
Merge branch 'master' into feature/discover-translations
pavel06081991 Nov 9, 2018
182c246
Merge branch 'master' into feature/discover-translations
pavel06081991 Nov 19, 2018
b1707b6
fix quotes
pavel06081991 Nov 19, 2018
48e5c51
Update snapshot
maryia-lapata Nov 20, 2018
8359381
fix quotes
pavel06081991 Nov 20, 2018
95d8929
Merge branch 'feature/discover-translations' of github.com:tibmt/kiba…
pavel06081991 Nov 20, 2018
d8fba05
update snapshots
pavel06081991 Nov 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,9 +44,26 @@ const DiscoverFetchError = ({ fetchError }) => {

body = (
<p>
You can address this error by editing the &lsquo;{fetchError.script}&rsquo; field
in <a href={url}>Management &gt; Index Patterns</a>,
under the &ldquo;Scripted fields&rdquo; tab.
<FormattedMessage
id="kbn.discover.fetchError.howToAddressErrorDescription"
defaultMessage="You can address this error by editing the {fetchErrorScript} field
in {managementLink}, under the {scriptedFields} tab."
values={{
fetchErrorScript: '&lsquo;' + fetchError.script + '&rsquo;',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tibmt @Bargs I don't think the quotes need escaping here. This is how it looks now:

scriptedFields: <FormattedMessage
id="kbn.discover.fetchError.scriptedFieldsText"
defaultMessage="&ldquo;Scripted fields&rdquo;"
/>,
managementLink: (
<a href={url}>
<FormattedMessage
id="kbn.discover.fetchError.managmentLinkText"
defaultMessage="Management &gt; Index Patterns"
/>
</a>
)
}}
/>
</p>
);
}
Expand Down Expand Up @@ -77,4 +95,4 @@ const DiscoverFetchError = ({ fetchError }) => {

const app = uiModules.get('apps/discover', ['react']);

app.directive('discoverFetchError', reactDirective => reactDirective(DiscoverFetchError));
app.directive('discoverFetchError', reactDirective => reactDirective(injectI18nProvider(DiscoverFetchError)));
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -92,6 +99,18 @@ app.directive('discoverField', function ($compile) {
$scope.onShowDetails(field, recompute);
detailScope = $scope.$new();
detailScope.warnings = getWarnings(field);
detailScope.getBucketAriaLabel = (bucket) => {
return i18n('kbn.discover.fieldChooser.discoverField.bucketAriaLabel', {
defaultMessage: 'Value: {value}',
values: {
value: bucket.display === ''
? i18n('kbn.discover.fieldChooser.discoverField.emptyStringText', {
defaultMessage: 'Empty string',
})
: bucket.display,
},
});
};

detailsElem = $(detailsHtml);
$compile(detailsElem)(detailScope);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sidebar-list" aria-label="Index and fields">
<section class="sidebar-list" aria-label="{{::'kbn.discover.fieldChooser.filter.indexAndFieldsSectionAriaLabel' | i18n: {defaultMessage: 'Index and fields'} }}">
<div ng-show="indexPatternList.length > 1">
<ui-select
class="index-pattern-selection"
Expand Down Expand Up @@ -32,9 +32,13 @@
</div>

<div class="dscSidebar__listHeader sidebar-list-header" ng-if="fields.length">
<h3 class="sidebar-list-header-label" id="selected_fields" tabindex="0">
Selected fields
</h3>
<h3
class="sidebar-list-header-label"
id="selected_fields"
tabindex="0"
i18n-id="kbn.discover.fieldChooser.filter.selectedFieldsTitle"
i18n-default-message="Selected fields"
></h3>
</div>
<ul class="list-unstyled dscFieldList--selected" >
<discover-field
Expand All @@ -49,9 +53,13 @@ <h3 class="sidebar-list-header-label" id="selected_fields" tabindex="0">
</ul>

<div class="sidebar-list-header sidebar-item euiFlexGroup euiFlexGroup--gutterMedium" ng-if="fields.length">
<h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex="0">
Available fields
</h3>
<h3
class="euiFlexItem sidebar-list-header-label"
id="available_fields"
tabindex="0"
i18n-id="kbn.discover.fieldChooser.filter.availableFieldsTitle"
i18n-default-message="Available fields"
></h3>

<div class="euiFlexItem euiFlexItem--flexGrowZero">
<button
Expand All @@ -72,7 +80,7 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
ng-class="{ 'kuiButton--basic': !filter.active, 'kuiButton--primary': filter.active, 'hidden-xs': !$parent.showFields, 'hidden-sm': !$parent.showFields }"
class="kuiButton kuiButton--small pull-right discover-field-filter-toggle"
ng-click="$parent.showFilter = !$parent.showFilter"
aria-label="{{$parent.showFilter ? 'Hide' : 'Show'}} field settings"
aria-label="{{toggleFieldFilterButtonAriaLabel}}"
aria-expanded="{{!!$parent.showFilter}}"
aria-controls="discoverFieldFilter"
data-test-subj="toggleFieldFilterButton"
Expand All @@ -85,9 +93,11 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
<div class="sidebar-item dscFieldDetails" ng-show="showFilter" id="discoverFieldFilter" data-test-subj="discoverFieldFilter">
<form role="form">
<div class="form-group">
<label for="discoverFieldChooserFilterAggregatable">
Aggregatable
</label>
<label
for="discoverFieldChooserFilterAggregatable"
i18n-id="kbn.discover.fieldChooser.filter.aggregatableLabel"
i18n-default-message="Aggregatable"
></label>
<select
id="discoverFieldChooserFilterAggregatable"
ng-options="opt.value as opt.label for opt in filter.boolOpts"
Expand All @@ -96,9 +106,11 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
</select>
</div>
<div class="form-group">
<label for="discoverFieldChooserFilterSearchable">
Searchable
</label>
<label
for="discoverFieldChooserFilterSearchable"
i18n-id="kbn.discover.fieldChooser.filter.searchableLabel"
i18n-default-message="Searchable"
></label>
<select
id="discoverFieldChooserFilterSearchable"
ng-options="opt.value as opt.label for opt in filter.boolOpts"
Expand All @@ -107,9 +119,11 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
</select>
</div>
<div class="form-group">
<label for="discoverFieldChooserFilterType">
Type
</label>
<label
for="discoverFieldChooserFilterType"
i18n-id="kbn.discover.fieldChooser.filter.typeLabel"
i18n-default-message="Type"
></label>
<select
id="discoverFieldChooserFilterType"
ng-options="field as field for field in fieldTypes"
Expand All @@ -118,9 +132,11 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
</select>
</div>
<div class="form-group">
<label for="discoverFieldChooserFilterFieldName">
Field name
</label>
<label
for="discoverFieldChooserFilterFieldName"
i18n-id="kbn.discover.fieldChooser.filter.fieldNameLabel"
i18n-default-message="Field name"
></label>
<input
id="discoverFieldChooserFilterFieldName"
type="text"
Expand All @@ -131,16 +147,19 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
<div class="form-group">
<label for="discoverFieldChooserHideMissingFields">
<input id="discoverFieldChooserHideMissingFields" type="checkbox" ng-model="filter.vals.missing">
Hide missing fields
<span
i18n-id="kbn.discover.fieldChooser.filter.hideMissingFieldsLabel"
i18n-default-message="Hide missing fields"
></span>
</label>
</div>
<button
ng-click="filter.reset()"
ng-disabled="!filter.active"
class="kuiButton kuiButton--danger kuiButton--fullWidth"
>
Reset filters
</button>
i18n-id="kbn.discover.fieldChooser.filter.resetFiltersButtonLabel"
i18n-default-message="Reset filters"
></button>
</form>
</div>

Expand All @@ -149,7 +168,10 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
ng-class="{ 'hidden-sm': !showFields, 'hidden-xs': !showFields }"
class="list-unstyled sidebar-well dscFieldList--popular">
<li class="sidebar-item sidebar-list-header">
<h6>Popular</h6>
<h6
i18n-id="kbn.discover.fieldChooser.filter.popularTitle"
i18n-default-message="Popular"
></h6>
</li>
<discover-field
ng-repeat="field in popularFields | filter:filter.isFieldFiltered"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { uiModules } from 'ui/modules';
import fieldChooserTemplate from './field_chooser.html';
const app = uiModules.get('apps/discover');

app.directive('discFieldChooser', function ($location, globalState, config, $route) {
app.directive('discFieldChooser', function ($location, globalState, config, $route, i18n) {
return {
restrict: 'E',
scope: {
Expand All @@ -47,6 +47,16 @@ app.directive('discFieldChooser', function ($location, globalState, config, $rou
},
template: fieldChooserTemplate,
link: function ($scope) {
$scope.$parent.$watch('showFilter', () =>{
$scope.toggleFieldFilterButtonAriaLabel = $scope.$parent.showFilter
? i18n('kbn.discover.fieldChooser.toggleFieldFilterButtonHideAriaLabel', {
defaultMessage: 'Hide field settings',
})
: i18n('kbn.discover.fieldChooser.toggleFieldFilterButtonShowAriaLabel', {
defaultMessage: 'Show field settings',
});
});

$scope.selectedIndexPattern = $scope.indexPatternList.find(
(pattern) => pattern.id === $scope.indexPattern.id
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<div class="dscFieldDetails">
<div class="kuiVerticalRhythmSmall">
<p class="euiText euiText--extraSmall euiTextColor--subdued" ng-show="!field.details.error">
Top 5 values in
<span
i18n-id="kbn.discover.fieldChooser.detailViews.topValuesInRecordsDescription"
i18n-default-message="Top 5 values in"
></span>
<span ng-if="!field.details.error">
<a
class="kuiLink"
Expand All @@ -14,7 +17,11 @@
ng-show="field.indexPattern.metaFields.includes(field.name) || field.scripted">
{{::field.details.exists}}
</span>
/ {{::field.details.total}} records
/ {{::field.details.total}}
<span
i18n-id="kbn.discover.fieldChooser.detailViews.recordsText"
i18n-default-message="records"
></span>
</span>
</p>

Expand All @@ -30,9 +37,14 @@
css-truncate
css-truncate-expandable="true"
class="dscFieldDetails__value"
aria-label="Value: {{:: bucket.display === '' ? 'Empty string' : bucket.display }}"
aria-label="{{::getBucketAriaLabel(bucket)}}"
>
{{::bucket.display}} <em ng-show="bucket.display === ''">Empty string</em>
{{::bucket.display}}
<em
ng-show="bucket.display === ''"
i18n-id="kbn.discover.fieldChooser.detailViews.emptyStringText"
i18n-default-message="Empty string"
></em>
</div>

<!-- Add/remove filter buttons -->
Expand All @@ -43,7 +55,7 @@
<button
class="dscFieldDetailsItem__button"
ng-click="onAddFilter(field, bucket.value, '+')"
aria-label="Filter for this value"
aria-label="{{::'kbn.discover.fieldChooser.detailViews.filterValueButtonAriaLabel' | i18n: {defaultMessage: 'Filter for this value'} }}"
data-test-subj="plus-{{::field.name}}-{{::bucket.display}}"
>
<span
Expand All @@ -55,7 +67,7 @@
<button
class="dscFieldDetailsItem__button"
ng-click="onAddFilter(field, bucket.value, '-')"
aria-label="Filter out this value"
aria-label="{{::'kbn.discover.fieldChooser.detailViews.filterOutValueButtonAriaLabel' | i18n: {defaultMessage: 'Filter out this value'} }}"
data-test-subj="minus-{{::field.name}}-{{::bucket.display}}"
>
<span
Expand Down Expand Up @@ -84,9 +96,16 @@
class="kuiButton kuiButton--secondary kuiButton--small kuiButton--fullWidth kuiVerticalRhythmSmall"
data-test-subj="fieldVisualize-{{::field.name}}"
>
Visualize
<span
i18n-id="kbn.discover.fieldChooser.detailViews.visualizeLinkText"
i18n-default-message="Visualize"
></span>
<span class="discover-field-vis-warning" ng-show="warnings.length" tooltip="{{warnings.join(' ')}}">
( {{::warnings.length}} <ng-pluralize count="warnings.length" when="{'1':'warning', 'other':'warnings'}"></ng-pluralize> <i aria-hidden="true" class="fa fa-warning"></i> )
( <span
i18n-id="kbn.discover.fieldChooser.detailViews.warningsText"
i18n-default-message="{warningsLength, plural, one {# warning} other {# warnings}}"
i18n-values="{ warningsLength: warnings.length }"
></span> <i aria-hidden="true" class="fa fa-warning"></i> )
</span>
</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';

function getFieldValues(hits, field) {
const name = field.name;
Expand All @@ -38,7 +39,9 @@ function getFieldValueCounts(params) {
|| params.field.type === 'geo_shape'
|| params.field.type === 'attachment'
) {
return { error: 'Analysis is not available for geo fields.' };
return { error: i18n.translate('kbn.discover.fieldChooser.fieldCalculator.analysisIsNotAvailableForGeoFieldsErrorMessage', {
defaultMessage: 'Analysis is not available for geo fields.',
}) };
}

const allValues = getFieldValues(params.hits, params.field);
Expand All @@ -59,9 +62,13 @@ function getFieldValueCounts(params) {

if (params.hits.length - missing === 0) {
return {
error: 'This field is present in your Elasticsearch mapping' +
' but not in the ' + params.hits.length + ' documents shown in the doc table.' +
' You may still be able to visualize or search on it.'
error: i18n.translate('kbn.discover.fieldChooser.fieldCalculator.fieldIsNotPresentInDocumentsErrorMessage', {
// eslint-disable-next-line max-len
defaultMessage: 'This field is present in your Elasticsearch mapping but not in the {hitsLength} documents shown in the doc table. You may still be able to visualize or search on it.',
values: {
hitsLength: params.hits.length,
},
})
};
}

Expand Down Expand Up @@ -89,7 +96,9 @@ function _groupValues(allValues, params) {

allValues.forEach(function (value) {
if (_.isObject(value) && !Array.isArray(value)) {
throw new Error('Analysis is not available for object fields');
throw new Error(i18n.translate('kbn.discover.fieldChooser.fieldCalculator.analysisIsNotAvailableForObjectFieldsErrorMessage', {
defaultMessage: 'Analysis is not available for object fields.',
}));
}

if (Array.isArray(value) && !params.grouped) {
Expand Down
Loading