Translate src/ui/public/notify (#27020)
This commit is contained in:
parent
0d647b13ae
commit
696047424c
|
@ -33,6 +33,7 @@ import {
|
|||
banners,
|
||||
} from '../../notify';
|
||||
import { SubUrlRouteFilterProvider } from './sub_url_route_filter';
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
|
||||
export function kbnChromeProvider(chrome, internals) {
|
||||
|
||||
|
@ -86,10 +87,12 @@ export function kbnChromeProvider(chrome, internals) {
|
|||
|
||||
// Banners
|
||||
ReactDOM.render(
|
||||
<GlobalBannerList
|
||||
banners={banners.list}
|
||||
subscribe={banners.onChange}
|
||||
/>,
|
||||
<I18nProvider>
|
||||
<GlobalBannerList
|
||||
banners={banners.list}
|
||||
subscribe={banners.onChange}
|
||||
/>
|
||||
</I18nProvider>,
|
||||
document.getElementById('globalBannerList')
|
||||
);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IHttpResponse } from 'angular';
|
||||
|
||||
export type AngularHttpError = IHttpResponse<{ message: string }>;
|
||||
|
@ -35,12 +36,20 @@ export function formatAngularHttpError(error: AngularHttpError) {
|
|||
// is an Angular $http "error object"
|
||||
if (error.status === -1) {
|
||||
// status = -1 indicates that the request was failed to reach the server
|
||||
return (
|
||||
'An HTTP request has failed to connect. ' +
|
||||
'Please check if the Kibana server is running and that your browser has a working connection, ' +
|
||||
'or contact your system administrator.'
|
||||
);
|
||||
return i18n.translate('common.ui.notify.fatalError.unavailableServerErrorMessage', {
|
||||
defaultMessage:
|
||||
'An HTTP request has failed to connect. ' +
|
||||
'Please check if the Kibana server is running and that your browser has a working connection, ' +
|
||||
'or contact your system administrator.',
|
||||
});
|
||||
}
|
||||
|
||||
return `Error ${error.status} ${error.statusText}: ${error.data.message}`;
|
||||
return i18n.translate('common.ui.notify.fatalError.errorStatusMessage', {
|
||||
defaultMessage: 'Error {errStatus} {errStatusText}: {errMessage}',
|
||||
values: {
|
||||
errStatus: error.status,
|
||||
errStatusText: error.statusText,
|
||||
errMessage: error.data.message,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { formatESMsg } from './format_es_msg';
|
||||
const has = _.has;
|
||||
|
||||
|
@ -46,11 +47,20 @@ export function formatMsg(err, source) {
|
|||
// is an Angular $http "error object"
|
||||
if (err.status === -1) {
|
||||
// status = -1 indicates that the request was failed to reach the server
|
||||
message += 'An HTTP request has failed to connect. ' +
|
||||
'Please check if the Kibana server is running and that your browser has a working connection, ' +
|
||||
'or contact your system administrator.';
|
||||
message += i18n.translate('common.ui.notify.toaster.unavailableServerErrorMessage', {
|
||||
defaultMessage: 'An HTTP request has failed to connect. ' +
|
||||
'Please check if the Kibana server is running and that your browser has a working connection, ' +
|
||||
'or contact your system administrator.',
|
||||
});
|
||||
} else {
|
||||
message += 'Error ' + err.status + ' ' + err.statusText + ': ' + err.data.message;
|
||||
message += i18n.translate('common.ui.notify.toaster.errorStatusMessage', {
|
||||
defaultMessage: 'Error {errStatus} {errStatusText}: {errMessage}',
|
||||
values: {
|
||||
errStatus: err.status,
|
||||
errStatusText: err.statusText,
|
||||
errMessage: err.data.message
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
// browsers format Error.stack differently; always include message
|
||||
export function formatStack(err) {
|
||||
if (err.stack && !~err.stack.indexOf(err.message)) {
|
||||
return 'Error: ' + err.message + '\n' + err.stack;
|
||||
return i18n.translate('common.ui.notify.toaster.errorMessage', {
|
||||
defaultMessage: `Error: {errorMessage}
|
||||
{errorStack}`,
|
||||
values: {
|
||||
errorMessage: err.message,
|
||||
errorStack: err.stack
|
||||
}
|
||||
});
|
||||
}
|
||||
return err.stack;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import _ from 'lodash';
|
|||
import { metadata } from '../metadata';
|
||||
import { formatMsg, formatStack } from './lib';
|
||||
import '../render_directive';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
const notifs = [];
|
||||
|
||||
|
@ -215,7 +216,9 @@ Notifier.prototype.error = function (err, opts, cb) {
|
|||
type: 'danger',
|
||||
content: formatMsg(err, this.from),
|
||||
icon: 'warning',
|
||||
title: 'Error',
|
||||
title: i18n.translate('common.ui.notify.toaster.errorTitle', {
|
||||
defaultMessage: 'Error',
|
||||
}),
|
||||
lifetime: Notifier.config.errorLifetime,
|
||||
actions: ['report', 'accept'],
|
||||
stack: formatStack(err)
|
||||
|
|
|
@ -28,6 +28,7 @@ import template from './partials/toaster.html';
|
|||
import './notify.less';
|
||||
import '../filters/markdown';
|
||||
import '../directives/truncated';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import {
|
||||
EuiCallOut,
|
||||
|
@ -102,7 +103,12 @@ function applyConfig(config) {
|
|||
|
||||
const banner = (
|
||||
<EuiCallOut
|
||||
title="Attention"
|
||||
title={(
|
||||
<FormattedMessage
|
||||
id="common.ui.notify.banner.attentionTitle"
|
||||
defaultMessage="Attention"
|
||||
/>
|
||||
)}
|
||||
iconType="help"
|
||||
>
|
||||
<MarkdownSimple data-test-subj="userDefinedBanner">
|
||||
|
@ -110,7 +116,10 @@ function applyConfig(config) {
|
|||
</MarkdownSimple>
|
||||
|
||||
<EuiButton type="primary" size="s" onClick={dismissBanner}>
|
||||
Close
|
||||
<FormattedMessage
|
||||
id="common.ui.notify.banner.closeButtonLabel"
|
||||
defaultMessage="Close"
|
||||
/>
|
||||
</EuiButton>
|
||||
</EuiCallOut>
|
||||
);
|
||||
|
|
|
@ -33,8 +33,9 @@
|
|||
class="kuiButton"
|
||||
ng-class="notif.getButtonClass()"
|
||||
ng-click="notif.cancelTimer(); notif.showStack = true"
|
||||
i18n-id="common.ui.notify.toaster.moreInfoButtonLabel"
|
||||
i18n-default-message="More Info"
|
||||
>
|
||||
More Info
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
@ -42,8 +43,9 @@
|
|||
class="kuiButton"
|
||||
ng-class="notif.getButtonClass()"
|
||||
ng-click="notif.showStack = false"
|
||||
i18n-id="common.ui.notify.toaster.lessInfoButtonLabel"
|
||||
i18n-default-message="Less Info"
|
||||
>
|
||||
Less Info
|
||||
</button>
|
||||
<button
|
||||
data-test-subj="notifierDismissButton"
|
||||
|
@ -52,8 +54,9 @@
|
|||
class="kuiButton"
|
||||
ng-class="notif.getButtonClass()"
|
||||
ng-click="notif.accept()"
|
||||
i18n-id="common.ui.notify.toaster.okButtonLabel"
|
||||
i18n-default-message="OK"
|
||||
>
|
||||
OK
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
@ -61,8 +64,9 @@
|
|||
class="kuiButton"
|
||||
ng-class="notif.getButtonClass()"
|
||||
ng-click="notif.address()"
|
||||
i18n-id="common.ui.notify.toaster.fixItButtonLabel"
|
||||
i18n-default-message="Fix it"
|
||||
>
|
||||
Fix it
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
|
Loading…
Reference in a new issue