From 96a2365028f3b3534053e8f97eb58010118f38d3 Mon Sep 17 00:00:00 2001 From: Coen Warmer Date: Mon, 26 Jun 2023 17:23:31 +0200 Subject: [PATCH] Move translations inline --- .../alerts_flyout/alerts_flyout_body.tsx | 46 +++++-- .../alerts_flyout/alerts_flyout_footer.tsx | 10 +- .../public/config/translations.ts | 125 ------------------ 3 files changed, 42 insertions(+), 139 deletions(-) delete mode 100644 x-pack/plugins/observability/public/config/translations.ts diff --git a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx index c476f1376d774..43f8866a5f061 100644 --- a/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx +++ b/x-pack/plugins/observability/public/components/alerts_flyout/alerts_flyout_body.tsx @@ -26,13 +26,13 @@ import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED, } from '@kbn/rule-data-utils'; +import { i18n } from '@kbn/i18n'; import { AlertLifecycleStatusBadge } from '@kbn/alerts-ui-shared'; import moment from 'moment-timezone'; import { useUiSetting } from '@kbn/kibana-react-plugin/public'; import { useKibana } from '../../utils/kibana_react'; import { asDuration } from '../../../common/utils/formatters'; import { paths } from '../../config/paths'; -import { translations } from '../../config/translations'; import { formatAlertEvaluationValue } from '../../utils/format_alert_evaluation_value'; import { RULE_DETAILS_PAGE_ID } from '../../pages/rule_details/constants'; import type { TopAlert } from '../../typings/alerts'; @@ -59,7 +59,9 @@ export function AlertsFlyoutBody({ alert, id: pageId }: FlyoutProps) { const overviewListItems = [ { - title: translations.alertsFlyout.statusLabel, + title: i18n.translate('xpack.observability.alertsFlyout.statusLabel', { + defaultMessage: 'Status', + }), description: ( {moment(alert.start).format(dateFormat)} ), }, { - title: translations.alertsFlyout.lastUpdatedLabel, + title: i18n.translate('xpack.observability.alertsFlyout.lastUpdatedLabel', { + defaultMessage: 'Last updated', + }), description: ( {moment(alert.lastUpdated).format(dateFormat)} @@ -82,25 +88,33 @@ export function AlertsFlyoutBody({ alert, id: pageId }: FlyoutProps) { ), }, { - title: translations.alertsFlyout.durationLabel, + title: i18n.translate('xpack.observability.alertsFlyout.durationLabel', { + defaultMessage: 'Duration', + }), description: asDuration(alert.fields[ALERT_DURATION], { extended: true }), }, { - title: translations.alertsFlyout.expectedValueLabel, + title: i18n.translate('xpack.observability.alertsFlyout.expectedValueLabel', { + defaultMessage: 'Expected value', + }), description: formatAlertEvaluationValue( alert.fields[ALERT_RULE_TYPE_ID], alert.fields[ALERT_EVALUATION_THRESHOLD] ), }, { - title: translations.alertsFlyout.actualValueLabel, + title: i18n.translate('xpack.observability.alertsFlyout.actualValueLabel', { + defaultMessage: 'Actual value', + }), description: formatAlertEvaluationValue( alert.fields[ALERT_RULE_TYPE_ID], alert.fields[ALERT_EVALUATION_VALUE] ), }, { - title: translations.alertsFlyout.ruleTypeLabel, + title: i18n.translate('xpack.observability.alertsFlyout.ruleTypeLabel', { + defaultMessage: 'Rule type', + }), description: alert.fields[ALERT_RULE_CATEGORY] ?? '-', }, ]; @@ -108,19 +122,29 @@ export function AlertsFlyoutBody({ alert, id: pageId }: FlyoutProps) { return ( -

{translations.alertsFlyout.reasonTitle}

+

+ {i18n.translate('xpack.observability.alertsFlyout.reasonTitle', { + defaultMessage: 'Reason', + })} +

{alert.reason} {!!linkToRule && ( - {translations.alertsFlyout.viewRulesDetailsLinkText} + {i18n.translate('xpack.observability.alertsFlyout.viewRulesDetailsLinkText', { + defaultMessage: 'View rule details', + })} )} -

{translations.alertsFlyout.documentSummaryTitle}

+

+ {i18n.translate('xpack.observability.alertsFlyout.documentSummaryTitle', { + defaultMessage: 'Document Summary', + })} +

- {translations.alertsFlyout.alertDetailsButtonText} + {i18n.translate('xpack.observability.alertsFlyout.alertsDetailsButtonText', { + defaultMessage: 'Alert details', + })} ); @@ -52,7 +54,9 @@ export function AlertsFlyoutFooter({ alert, isInApp }: FlyoutProps & { isInApp: data-test-subj="alertsFlyoutViewInAppButton" fill > - {translations.alertsFlyout.viewInAppButtonText} + {i18n.translate('xpack.observability.alertsFlyout.viewInAppButtonText', { + defaultMessage: 'View in app', + })} ); diff --git a/x-pack/plugins/observability/public/config/translations.ts b/x-pack/plugins/observability/public/config/translations.ts deleted file mode 100644 index 042650b94c084..0000000000000 --- a/x-pack/plugins/observability/public/config/translations.ts +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { i18n } from '@kbn/i18n'; - -export const translations = { - alertsTable: { - viewDetailsTextLabel: i18n.translate('xpack.observability.alertsTable.viewDetailsTextLabel', { - defaultMessage: 'View details', - }), - viewInAppTextLabel: i18n.translate('xpack.observability.alertsTable.viewInAppTextLabel', { - defaultMessage: 'View in app', - }), - moreActionsTextLabel: i18n.translate('xpack.observability.alertsTable.moreActionsTextLabel', { - defaultMessage: 'More actions', - }), - notEnoughPermissions: i18n.translate('xpack.observability.alertsTable.notEnoughPermissions', { - defaultMessage: 'Additional privileges required', - }), - statusColumnDescription: i18n.translate( - 'xpack.observability.alertsTGrid.statusColumnDescription', - { - defaultMessage: 'Alert Status', - } - ), - lastUpdatedColumnDescription: i18n.translate( - 'xpack.observability.alertsTGrid.lastUpdatedColumnDescription', - { - defaultMessage: 'Last updated', - } - ), - durationColumnDescription: i18n.translate( - 'xpack.observability.alertsTGrid.durationColumnDescription', - { - defaultMessage: 'Duration', - } - ), - reasonColumnDescription: i18n.translate( - 'xpack.observability.alertsTGrid.reasonColumnDescription', - { - defaultMessage: 'Reason', - } - ), - actionsTextLabel: i18n.translate('xpack.observability.alertsTable.actionsTextLabel', { - defaultMessage: 'Actions', - }), - loadingTextLabel: i18n.translate('xpack.observability.alertsTable.loadingTextLabel', { - defaultMessage: 'loading alerts', - }), - footerTextLabel: i18n.translate('xpack.observability.alertsTable.footerTextLabel', { - defaultMessage: 'alerts', - }), - showingAlertsTitle: (totalAlerts: number) => - i18n.translate('xpack.observability.alertsTable.showingAlertsTitle', { - values: { totalAlerts }, - defaultMessage: '{totalAlerts, plural, =1 {alert} other {alerts}}', - }), - viewRuleDetailsButtonText: i18n.translate( - 'xpack.observability.alertsTable.viewRuleDetailsButtonText', - { - defaultMessage: 'View rule details', - } - ), - viewAlertDetailsButtonText: i18n.translate( - 'xpack.observability.alertsTable.viewAlertDetailsButtonText', - { - defaultMessage: 'View alert details', - } - ), - viewAlertDetailsPageButtonText: i18n.translate( - 'xpack.observability.alertsTable.viewAlertDetailsPageButtonText', - { - defaultMessage: 'View alert page', - } - ), - }, - alertsFlyout: { - statusLabel: i18n.translate('xpack.observability.alertsFlyout.statusLabel', { - defaultMessage: 'Status', - }), - lastUpdatedLabel: i18n.translate('xpack.observability.alertsFlyout.lastUpdatedLabel', { - defaultMessage: 'Last updated', - }), - startedAtLabel: i18n.translate('xpack.observability.alertsFlyout.startedAtLabel', { - defaultMessage: 'Started at', - }), - durationLabel: i18n.translate('xpack.observability.alertsFlyout.durationLabel', { - defaultMessage: 'Duration', - }), - expectedValueLabel: i18n.translate('xpack.observability.alertsFlyout.expectedValueLabel', { - defaultMessage: 'Expected value', - }), - actualValueLabel: i18n.translate('xpack.observability.alertsFlyout.actualValueLabel', { - defaultMessage: 'Actual value', - }), - ruleTypeLabel: i18n.translate('xpack.observability.alertsFlyout.ruleTypeLabel', { - defaultMessage: 'Rule type', - }), - reasonTitle: i18n.translate('xpack.observability.alertsFlyout.reasonTitle', { - defaultMessage: 'Reason', - }), - viewRulesDetailsLinkText: i18n.translate( - 'xpack.observability.alertsFlyout.viewRulesDetailsLinkText', - { - defaultMessage: 'View rule details', - } - ), - documentSummaryTitle: i18n.translate('xpack.observability.alertsFlyout.documentSummaryTitle', { - defaultMessage: 'Document Summary', - }), - viewInAppButtonText: i18n.translate('xpack.observability.alertsFlyout.viewInAppButtonText', { - defaultMessage: 'View in app', - }), - alertDetailsButtonText: i18n.translate( - 'xpack.observability.alertsFlyout.alertsDetailsButtonText', - { - defaultMessage: 'Alert details', - } - ), - }, -};