Skip to content

Commit

Permalink
[i18n] Translate missing labels in context (#26970)
Browse files Browse the repository at this point in the history
* Translate context and docs

* Fix issues

* Fix issues

* Fix issues
  • Loading branch information
Nox911 authored Dec 14, 2018
1 parent 34a2a47 commit 83d6764
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 47 deletions.
6 changes: 4 additions & 2 deletions src/legacy/core_plugins/kibana/public/context/api/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import _ from 'lodash';

import { SearchSourceProvider } from 'ui/courier';

export function fetchAnchorProvider(indexPatterns, Private) {
export function fetchAnchorProvider(indexPatterns, Private, i18n) {
const SearchSource = Private(SearchSourceProvider);

return async function fetchAnchor(
Expand Down Expand Up @@ -54,7 +54,9 @@ export function fetchAnchorProvider(indexPatterns, Private) {
const response = await searchSource.fetch();

if (_.get(response, ['hits', 'total'], 0) < 1) {
throw new Error('Failed to load anchor document.');
throw new Error(i18n('kbn.context.failedToLoadAnchorDocumentErrorDescription', {
defaultMessage: 'Failed to load anchor document.'
}));
}

return {
Expand Down
88 changes: 65 additions & 23 deletions src/legacy/core_plugins/kibana/public/context/app.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<div class="kuiLocalNav" ng-if="!k7design">
<div class="kuiLocalNavRow">
<div class="kuiLocalNavRow__section">
<div class="kuiLocalTitle" role="heading" aria-level="1">
Surrounding Documents in {{ contextApp.state.queryParameters.indexPatternId }}
</div>
<div
class="kuiLocalTitle"
role="heading"
aria-level="1"
i18n-id="kbn.context.surroundingDocumentsDescription"
i18n-default-message="Surrounding Documents in {indexPatternId}"
i18n-values="{
indexPatternId: contextApp.state.queryParameters.indexPatternId
}"
></div>
</div>
</div>
<div class="kuiLocalNavRow kuiLocalNavRow--secondary">
Expand All @@ -25,31 +32,46 @@
<div class="kuiInfoPanel kuiInfoPanel--error kuiVerticalRhythm">
<div class="kuiInfoPanelHeader">
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--error fa-warning"></span>
<span class="kuiInfoPanelHeader__title">
Failed to load the anchor document
</span>
<span
class="kuiInfoPanelHeader__title"
i18n-id="kbn.context.failedToLoadAnchorDocumentDescription"
i18n-default-message="Failed to load the anchor document"
></span>
</div>

<div class="kuiInfoPanelBody">
<div
class="kuiInfoPanelBody__message"
ng-if="contextApp.state.loadingStatus.anchor.reason === contextApp.constants.FAILURE_REASONS.INVALID_TIEBREAKER"
i18n-id="kbn.context.noSearchableTiebreakerFieldDescription"
i18n-default-message="No searchable tiebreaker field could be found in the index pattern {indexPatternId}. Please change the advanced setting {tieBreakerFields} to include a valid field for this index pattern."
i18n-values="{
indexPatternId: contextApp.state.queryParameters.indexPatternId,
html_tieBreakerFields: '<code>context:tieBreakerFields</code>'
}"
>
No searchable tiebreaker field could be found in the index pattern
{{ contextApp.state.queryParameters.indexPatternId}}.

Please change the advanced setting
<code>context:tieBreakerFields</code> to include a valid field for this
index pattern.
</div>
<div
class="kuiInfoPanelBody__message"
ng-if="contextApp.state.loadingStatus.anchor.reason === contextApp.constants.FAILURE_REASONS.UNKNOWN"
>
Please reload or visit
<a ng-href="{{ contextApp.state.navigation.discover.url }}">Discover</a>
to select a valid anchor document.
</div>
<span
i18n-id="kbn.context.reloadPageDescription.reloadOrVisitTextMessage"
i18n-default-message="Please reload or visit"
i18n-description="Part of composite text kbn.context.reloadPageDescription.reloadOrVisitTextMessage + kbn.context.reloadPageDescription.discoverLinkText + kbn.context.reloadPageDescription.selectValidAnchorDocumentTextMessage"
></span>
<a
ng-href="{{ contextApp.state.navigation.discover.url }}"
i18n-id="kbn.context.reloadPageDescription.discoverLinkText"
i18n-default-message="Discover"
i18n-description="Part of composite text kbn.context.reloadPageDescription.reloadOrVisitTextMessage + kbn.context.reloadPageDescription.discoverLinkText + kbn.context.reloadPageDescription.selectValidAnchorDocumentTextMessage"
></a>
<span
i18n-id="kbn.context.reloadPageDescription.selectValidAnchorDocumentTextMessage"
i18n-default-message="to select a valid anchor document."
i18n-description="Part of composite text kbn.context.reloadPageDescription.reloadOrVisitTextMessage + kbn.context.reloadPageDescription.discoverLinkText + kbn.context.reloadPageDescription.selectValidAnchorDocumentTextMessage"
></span>
</div>
</div>
</div>
</div>
Expand All @@ -70,15 +92,24 @@
icon="'fa-chevron-up'"
ng-click="contextApp.actions.fetchMorePredecessorRows()"
>
Load {{ contextApp.state.queryParameters.defaultStepSize }} more
<span
i18n-id="kbn.context.loadMoreDescription"
i18n-default-message="Load {defaultStepSize} more"
i18n-values="{
defaultStepSize: contextApp.state.queryParameters.defaultStepSize
}"
></span>
</context-loading-button>
<context-size-picker
count="contextApp.state.queryParameters.predecessorCount"
data-test-subj="predecessorCountPicker"
is-disabled="contextApp.state.loadingStatus.anchor.status !== contextApp.constants.LOADING_STATUS.LOADED"
on-change-count="contextApp.actions.fetchGivenPredecessorRows"
></context-size-picker>
<span>newer documents</span>
<span
i18n-id="kbn.context.newerDocumentsDescription"
i18n-default-message="newer documents"
></span>
<span
class="kuiStatusText kuiStatusText--warning"
ng-if="(contextApp.state.loadingStatus.predecessors.status === contextApp.constants.LOADING_STATUS.LOADED)
Expand All @@ -101,9 +132,11 @@
].includes(contextApp.state.loadingStatus.anchor.status)"
class="kuiPanel kuiPanel--centered kuiVerticalRhythm"
>
<div class="kuiTableInfo">
Loading&hellip;
</div>
<div
class="kuiTableInfo"
i18n-id="kbn.context.loadingDescription"
i18n-default-message="Loading…"
></div>
</div>

<!-- Table -->
Expand Down Expand Up @@ -136,15 +169,24 @@
icon="'fa-chevron-down'"
ng-click="contextApp.actions.fetchMoreSuccessorRows()"
>
Load {{ contextApp.state.queryParameters.defaultStepSize }} more
<span
i18n-id="kbn.context.loadMoreDescription"
i18n-default-message="Load {defaultStepSize} more"
i18n-values="{
defaultStepSize: contextApp.state.queryParameters.defaultStepSize
}"
></span>
</context-loading-button>
<context-size-picker
count="contextApp.state.queryParameters.successorCount"
data-test-subj="successorCountPicker"
is-disabled="contextApp.state.loadingStatus.anchor.status !== contextApp.constants.LOADING_STATUS.LOADED"
on-change-count="contextApp.actions.fetchGivenSuccessorRows"
></context-size-picker>
<div>older documents</div>
<div
i18n-id="kbn.context.olderDocumentsDescription"
i18n-default-message="older documents"
></div>
<span
class="kuiStatusText kuiStatusText--warning"
ng-if="(contextApp.state.loadingStatus.successors.status === contextApp.constants.LOADING_STATUS.LOADED)
Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/kibana/public/context/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function ContextAppController($scope, config, Private) {
);
}


function createInitialState(defaultStepSize, tieBreakerField, discoverUrl) {
return {
queryParameters: createInitialQueryParametersState(defaultStepSize, tieBreakerField),
Expand Down
10 changes: 7 additions & 3 deletions src/legacy/core_plugins/kibana/public/context/query/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { fetchContextProvider } from '../api/context';
import { QueryParameterActionsProvider } from '../query_parameters';
import { FAILURE_REASONS, LOADING_STATUS } from './constants';

export function QueryActionsProvider(courier, Private, Promise) {
export function QueryActionsProvider(courier, Private, Promise, i18n) {
const fetchAnchor = Private(fetchAnchorProvider);
const { fetchPredecessors, fetchSuccessors } = Private(fetchContextProvider);
const {
Expand Down Expand Up @@ -81,7 +81,9 @@ export function QueryActionsProvider(courier, Private, Promise) {
(error) => {
setFailedStatus(state)('anchor', { error });
toastNotifications.addDanger({
title: 'Unable to load the anchor document',
title: i18n('kbn.context.unableToLoadAnchorDocumentDescription', {
defaultMessage: 'Unable to load the anchor document'
}),
text: <MarkdownSimple>{error.message}</MarkdownSimple>,
});
throw error;
Expand Down Expand Up @@ -125,7 +127,9 @@ export function QueryActionsProvider(courier, Private, Promise) {
(error) => {
setFailedStatus(state)('predecessors', { error });
toastNotifications.addDanger({
title: 'Unable to load documents',
title: i18n('kbn.context.unableToLoadDocumentDescription', {
defaultMessage: 'Unable to load documents'
}),
text: <MarkdownSimple>{error.message}</MarkdownSimple>,
});
throw error;
Expand Down
52 changes: 33 additions & 19 deletions src/legacy/core_plugins/kibana/public/doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<div class="kuiLocalNav" ng-if="!k7design">
<div class="kuiLocalNavRow">
<div class="kuiLocalNavRow__section">
<div class="kuiLocalTitle">
Single Document
</div>
<div
class="kuiLocalTitle"
i18n-id="kbn.doc.singleDocumentTitle"
i18n-default-message="Single Document"
></div>
</div>
</div>
<div class="kuiLocalNavRow kuiLocalNavRow--secondary">
Expand All @@ -17,7 +19,9 @@
<div
class="kuiLocalTab kuiLocalTab-isSelected"
ng-if="!hit"
>Unknown Id</div>
i18n-id="kbn.doc.unknownIdTitle"
i18n-default-message="Unknown Id"
></div>
</div>
</div>
</div>
Expand All @@ -28,14 +32,18 @@
<div class="kuiInfoPanel kuiInfoPanel--error kuiVerticalRhythm">
<div class="kuiInfoPanelHeader">
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--error fa-warning"></span>
<span class="kuiInfoPanelHeader__title">
Failed to locate document
</span>
<span
class="kuiInfoPanelHeader__title"
i18n-id="kbn.doc.failedToLocateDocumentDescription"
i18n-default-message="Failed to locate document"
></span>
</div>
<div class="kuiInfoPanelBody">
<div class="kuiInfoPanelBody__message">
Unfortunately I could not find any documents matching that id, of that type, in that index. I tried really hard. I wanted it to be there. Sometimes I swear documents grow legs and just walk out of the index. Sneaky. I wish I could offer some advice here, something to make you feel better
</div>
<div
class="kuiInfoPanelBody__message"
i18n-id="kbn.doc.couldNotFindDocumentsDescription"
i18n-default-message="Unfortunately I could not find any documents matching that id, of that type, in that index. I tried really hard. I wanted it to be there. Sometimes I swear documents grow legs and just walk out of the index. Sneaky. I wish I could offer some advice here, something to make you feel better"
></div>
</div>
</div>
</div>
Expand All @@ -45,24 +53,30 @@
<div class="kuiInfoPanel kuiInfoPanel--error kuiVerticalRhythm">
<div class="kuiInfoPanelHeader">
<span class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--error fa-warning"></span>
<span class="kuiInfoPanelHeader__title">
Failed to execute query
</span>
<span
class="kuiInfoPanelHeader__title"
i18n-id="kbn.doc.failedToExecuteQueryDescription"
i18n-default-message="Failed to execute query"
></span>
</div>
<div class="kuiInfoPanelBody">
<div class="kuiInfoPanelBody__message">
Oh no. Something went very wrong. Its not just that I couldn't find your document, I couldn't even try. The index was missing, or the type. Go check out Elasticsearch, something isn't quite right here.
</div>
<div
class="kuiInfoPanelBody__message"
i18n-id="kbn.doc.somethingWentWrongDescription"
i18n-default-message="Oh no. Something went very wrong. Its not just that I couldn't find your document, I couldn't even try. The index was missing, or the type. Go check out Elasticsearch, something isn't quite right here."
></div>
</div>
</div>
</div>

<!-- loading -->
<div class="kuiViewContentItem" ng-if="status === undefined">
<div class="kuiPanel kuiPanel--centered">
<div class="kuiTableInfo">
Loading&hellip;
</div>
<div
class="kuiTableInfo"
i18n-id="kbn.doc.loadingDescription"
i18n-default-message="Loading…"
></div>
</div>
</div>

Expand Down

0 comments on commit 83d6764

Please sign in to comment.