mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[i18n] Translate courier (#26514)
* Translate courier * Fix issues * Fix issues
This commit is contained in:
parent
99514d6aba
commit
f08313297f
7 changed files with 87 additions and 22 deletions
|
@ -23,6 +23,7 @@ import { IsRequestProvider } from './is_request';
|
|||
import { MergeDuplicatesRequestProvider } from './merge_duplicate_requests';
|
||||
import { RequestStatus } from './req_status';
|
||||
import { SerializeFetchParamsProvider } from './request/serialize_fetch_params';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function CallClientProvider(Private, Promise, es, config) {
|
||||
const errorAllowExplicitIndex = Private(ErrorAllowExplicitIndexProvider);
|
||||
|
@ -95,7 +96,11 @@ export function CallClientProvider(Private, Promise, es, config) {
|
|||
// handle a request being aborted while being fetched
|
||||
const requestWasAborted = Promise.method(function (searchRequest, index) {
|
||||
if (searchRequestsAndStatuses[index] === ABORTED) {
|
||||
defer.reject(new Error('Request was aborted twice?'));
|
||||
defer.reject(new Error(
|
||||
i18n.translate('common.ui.courier.fetch.requestWasAbortedTwiceErrorMessage', {
|
||||
defaultMessage: 'Request was aborted twice?',
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
requestsToFetchCount--;
|
||||
|
|
|
@ -21,6 +21,7 @@ import { toastNotifications } from '../../notify';
|
|||
import { RequestFailure } from '../../errors';
|
||||
import { RequestStatus } from './req_status';
|
||||
import { SearchError } from '../search_strategy/search_error';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function CallResponseHandlersProvider(Private, Promise) {
|
||||
const ABORTED = RequestStatus.ABORTED;
|
||||
|
@ -36,13 +37,18 @@ export function CallResponseHandlersProvider(Private, Promise) {
|
|||
|
||||
if (response.timed_out) {
|
||||
toastNotifications.addWarning({
|
||||
title: 'Data might be incomplete because your request timed out',
|
||||
title: i18n.translate('common.ui.courier.fetch.requestTimedOutNotificationMessage', {
|
||||
defaultMessage: 'Data might be incomplete because your request timed out',
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (response._shards && response._shards.failed) {
|
||||
toastNotifications.addWarning({
|
||||
title: `${response._shards.failed} of ${response._shards.total} shards failed`,
|
||||
title: i18n.translate('common.ui.courier.fetch.shardsFailedNotificationMessage', {
|
||||
defaultMessage: '{shardsFailed} of {shardsTotal} shards failed',
|
||||
values: { shardsFailed: response._shards.failed, shardsTotal: response._shards.total }
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import { CallClientProvider } from './call_client';
|
|||
import { CallResponseHandlersProvider } from './call_response_handlers';
|
||||
import { ContinueIncompleteProvider } from './continue_incomplete';
|
||||
import { RequestStatus } from './req_status';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
/**
|
||||
* Fetch now provider should be used if you want the results searched and returned immediately.
|
||||
|
@ -95,7 +96,11 @@ export function FetchNowProvider(Private, Promise) {
|
|||
return null;
|
||||
case DUPLICATE:
|
||||
case INCOMPLETE:
|
||||
throw new Error('Failed to clear incomplete or duplicate request from responses.');
|
||||
throw new Error(
|
||||
i18n.translate('common.ui.courier.fetch.failedToClearRequestErrorMessage', {
|
||||
defaultMessage: 'Failed to clear incomplete or duplicate request from responses.',
|
||||
})
|
||||
);
|
||||
default:
|
||||
return resp;
|
||||
}
|
||||
|
|
|
@ -21,11 +21,18 @@ import moment from 'moment';
|
|||
|
||||
import { searchRequestQueue } from '../../../search_request_queue';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export function SearchRequestProvider(Promise) {
|
||||
class SearchRequest {
|
||||
constructor({ source, defer, errorHandler }) {
|
||||
if (!errorHandler) {
|
||||
throw new Error('errorHandler is required');
|
||||
throw new Error(
|
||||
i18n.translate('common.ui.courier.fetch.requireErrorHandlerErrorMessage', {
|
||||
defaultMessage: '{errorHandler} is required',
|
||||
values: { errorHandler: 'errorHandler' }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
this.errorHandler = errorHandler;
|
||||
|
@ -99,7 +106,11 @@ export function SearchRequestProvider(Promise) {
|
|||
|
||||
start() {
|
||||
if (this.started) {
|
||||
throw new TypeError('Unable to start request because it has already started');
|
||||
throw new TypeError(
|
||||
i18n.translate('common.ui.courier.fetch.unableStartRequestErrorMessage', {
|
||||
defaultMessage: 'Unable to start request because it has already started',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
this.started = true;
|
||||
|
@ -133,7 +144,12 @@ export function SearchRequestProvider(Promise) {
|
|||
}
|
||||
|
||||
continue() {
|
||||
throw new Error('Unable to continue ' + this.type + ' request');
|
||||
throw new Error(
|
||||
i18n.translate('common.ui.courier.fetch.unableContinueRequestErrorMessage', {
|
||||
defaultMessage: 'Unable to continue {type} request',
|
||||
values: { type: this.type }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
retry() {
|
||||
|
|
|
@ -38,18 +38,23 @@ import { SearchSourceProvider } from '../search_source';
|
|||
import { SavedObjectsClientProvider, findObjectByTitle } from '../../saved_objects';
|
||||
import { migrateLegacyQuery } from '../../utils/migrate_legacy_query';
|
||||
import { recentlyAccessed } from '../../persisted_log';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
/**
|
||||
* An error message to be used when the user rejects a confirm overwrite.
|
||||
* @type {string}
|
||||
*/
|
||||
const OVERWRITE_REJECTED = 'Overwrite confirmation was rejected';
|
||||
const OVERWRITE_REJECTED = i18n.translate('common.ui.courier.savedObject.overwriteRejectedDescription', {
|
||||
defaultMessage: 'Overwrite confirmation was rejected'
|
||||
});
|
||||
|
||||
/**
|
||||
* An error message to be used when the user rejects a confirm save with duplicate title.
|
||||
* @type {string}
|
||||
*/
|
||||
const SAVE_DUPLICATE_REJECTED = 'Save with duplicate title confirmation was rejected';
|
||||
const SAVE_DUPLICATE_REJECTED = i18n.translate('common.ui.courier.savedObject.saveDuplicateRejectedDescription', {
|
||||
defaultMessage: 'Save with duplicate title confirmation was rejected'
|
||||
});
|
||||
|
||||
/**
|
||||
* @param error {Error} the error
|
||||
|
@ -312,9 +317,17 @@ export function SavedObjectProvider(Promise, Private, Notifier, confirmModalProm
|
|||
.catch(err => {
|
||||
// record exists, confirm overwriting
|
||||
if (_.get(err, 'res.status') === 409) {
|
||||
const confirmMessage = `Are you sure you want to overwrite ${this.title}?`;
|
||||
const confirmMessage = i18n.translate('common.ui.courier.savedObject.confirmModal.overwriteConfirmationMessage', {
|
||||
defaultMessage: 'Are you sure you want to overwrite {title}?',
|
||||
values: { title: this.title }
|
||||
});
|
||||
|
||||
return confirmModalPromise(confirmMessage, { confirmButtonText: `Overwrite ${this.getDisplayName()}` })
|
||||
return confirmModalPromise(confirmMessage, {
|
||||
confirmButtonText: i18n.translate('common.ui.courier.savedObject.confirmModal.overwriteButtonLabel', {
|
||||
defaultMessage: 'Overwrite {name}',
|
||||
values: { name: this.getDisplayName() }
|
||||
})
|
||||
})
|
||||
.then(() => savedObjectsClient.create(esType, source, this.creationOpts({ overwrite: true })))
|
||||
.catch(() => Promise.reject(new Error(OVERWRITE_REJECTED)));
|
||||
}
|
||||
|
@ -323,10 +336,17 @@ export function SavedObjectProvider(Promise, Private, Notifier, confirmModalProm
|
|||
};
|
||||
|
||||
const displayDuplicateTitleConfirmModal = () => {
|
||||
const confirmMessage =
|
||||
`A ${this.getDisplayName()} with the title '${this.title}' already exists. Would you like to save anyway?`;
|
||||
const confirmMessage = i18n.translate('common.ui.courier.savedObject.confirmModal.saveDuplicateConfirmationMessage', {
|
||||
defaultMessage: `A {name} with the title '{title}' already exists. Would you like to save anyway?`,
|
||||
values: { title: this.title, name: this.getDisplayName() }
|
||||
});
|
||||
|
||||
return confirmModalPromise(confirmMessage, { confirmButtonText: `Save ${this.getDisplayName()}` })
|
||||
return confirmModalPromise(confirmMessage, {
|
||||
confirmButtonText: i18n.translate('common.ui.courier.savedObject.confirmModal.saveDuplicateButtonLabel', {
|
||||
defaultMessage: 'Save {name}',
|
||||
values: { name: this.getDisplayName() }
|
||||
})
|
||||
})
|
||||
.catch(() => Promise.reject(new Error(SAVE_DUPLICATE_REJECTED)));
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<div ng-hide="!savedObject.id || savedObject.isSaving">
|
||||
<div ng-hide="!savedObject.isTitleChanged() || savedObject.copyOnSave" class="kuiLocalDropdownWarning kuiVerticalRhythmSmall">
|
||||
In previous versions of Kibana, changing the name of a {{savedObject.getDisplayName()}} would make a copy with the new name. Use the 'Save as a new {{savedObject.getDisplayName()}}' checkbox to do this now.
|
||||
</div>
|
||||
<div
|
||||
ng-hide="!savedObject.isTitleChanged() || savedObject.copyOnSave"
|
||||
class="kuiLocalDropdownWarning kuiVerticalRhythmSmall"
|
||||
i18n-id="common.ui.courier.savedObject.howToSaveAsNewDescription"
|
||||
i18n-default-message="In previous versions of Kibana, changing the name of a {savedObjectName} would make a copy with the new name. Use the 'Save as a new {savedObjectName}' checkbox to do this now."
|
||||
i18n-values="{ savedObjectName: savedObject.getDisplayName() }"
|
||||
i18n-description="'Save as a new {savedObjectName}' refers to common.ui.courier.savedObject.saveAsNewLabel and should be the same text."
|
||||
></div>
|
||||
|
||||
<label class="kuiCheckBoxLabel kuiVerticalRhythmSmall">
|
||||
<input
|
||||
|
@ -12,9 +17,12 @@
|
|||
ng-checked="savedObject.copyOnSave"
|
||||
>
|
||||
|
||||
<span class="kuiCheckBoxLabel__text">
|
||||
Save as a new {{savedObject.getDisplayName()}}
|
||||
</span>
|
||||
<span
|
||||
class="kuiCheckBoxLabel__text"
|
||||
i18n-id="common.ui.courier.savedObject.saveAsNewLabel"
|
||||
i18n-default-message="Save as a new {savedObjectName}"
|
||||
i18n-values="{ savedObjectName: savedObject.getDisplayName() }"
|
||||
></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import { SearchError } from './search_error';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export const noOpSearchStrategy = {
|
||||
id: 'noOp',
|
||||
|
@ -25,8 +26,12 @@ export const noOpSearchStrategy = {
|
|||
search: async () => {
|
||||
const searchError = new SearchError({
|
||||
status: '418', // "I'm a teapot" error
|
||||
title: 'No search strategy registered',
|
||||
message: `Couldn't find a search strategy for the search request`,
|
||||
title: i18n.translate('common.ui.courier.noSearchStrategyRegisteredErrorMessageTitle', {
|
||||
defaultMessage: 'No search strategy registered',
|
||||
}),
|
||||
message: i18n.translate('common.ui.courier.noSearchStrategyRegisteredErrorMessageDescription', {
|
||||
defaultMessage: `Couldn't find a search strategy for the search request`,
|
||||
}),
|
||||
type: 'NO_OP_SEARCH_STRATEGY',
|
||||
path: '',
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue