From 7f408c657c636217c0c2b20650d57b6dbfc54300 Mon Sep 17 00:00:00 2001 From: rbrtj Date: Thu, 19 Dec 2024 10:08:06 +0100 Subject: [PATCH] internationalization for cases toast messages && plural for anomaly chart --- .../shared/aiops/public/cases/constants.ts | 14 +++++++++++--- .../contexts/kibana/use_cases_modal.ts | 4 ++-- .../explorer/anomaly_context_menu.tsx | 2 +- .../shared/ml/public/cases/constants.ts | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/x-pack/platform/plugins/shared/aiops/public/cases/constants.ts b/x-pack/platform/plugins/shared/aiops/public/cases/constants.ts index b2f730c910288..142a70523a770 100644 --- a/x-pack/platform/plugins/shared/aiops/public/cases/constants.ts +++ b/x-pack/platform/plugins/shared/aiops/public/cases/constants.ts @@ -5,11 +5,19 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; + /** * Titles for the cases toast messages */ export const TITLES = { - CHANGE_POINT_DETECTION: 'Change point detection', - LOG_RATE_ANALYSIS: 'Log rate analysis', - PATTERN_ANALYSIS: 'Log pattern analysis', + CHANGE_POINT_DETECTION: i18n.translate('xpack.aiops.cases.changePointDetectionTitle', { + defaultMessage: 'Change point chart', + }), + LOG_RATE_ANALYSIS: i18n.translate('xpack.aiops.cases.logRateAnalysisTitle', { + defaultMessage: 'Log rate analysis', + }), + PATTERN_ANALYSIS: i18n.translate('xpack.aiops.cases.logPatternAnalysisTitle', { + defaultMessage: 'Log pattern analysis', + }), }; diff --git a/x-pack/platform/plugins/shared/ml/public/application/contexts/kibana/use_cases_modal.ts b/x-pack/platform/plugins/shared/ml/public/application/contexts/kibana/use_cases_modal.ts index 37d254506628d..f24a541884555 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/contexts/kibana/use_cases_modal.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/contexts/kibana/use_cases_modal.ts @@ -61,7 +61,7 @@ export const useCasesModal = ( ], }); }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [embeddableType] + + [embeddableType, selectCaseModal] ); }; diff --git a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx index c8d87274ead24..b66ec7dc2ed7d 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx +++ b/x-pack/platform/plugins/shared/ml/public/application/explorer/anomaly_context_menu.tsx @@ -102,7 +102,7 @@ export const AnomalyContextMenu: FC = ({ const openCasesModal = useCasesModal( ANOMALY_EXPLORER_CHARTS_EMBEDDABLE_TYPE, - TITLES.ANOMALY_CHARTS + TITLES.ANOMALY_CHARTS(maxSeriesToPlot) ); const canEditDashboards = capabilities.dashboard?.createNew ?? false; diff --git a/x-pack/platform/plugins/shared/ml/public/cases/constants.ts b/x-pack/platform/plugins/shared/ml/public/cases/constants.ts index 8ffe2491886cc..01aef113f246a 100644 --- a/x-pack/platform/plugins/shared/ml/public/cases/constants.ts +++ b/x-pack/platform/plugins/shared/ml/public/cases/constants.ts @@ -5,11 +5,23 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; + /** * Titles for the cases toast messages */ export const TITLES = { - ANOMALY_TIMELINE: 'Anomaly timeline', - ANOMALY_CHARTS: 'Anomaly charts', - SINGLE_METRIC_VIEWER: 'Single metric viewer', + ANOMALY_TIMELINE: i18n.translate('xpack.ml.cases.anomalyTimelineTitle', { + defaultMessage: 'Anomaly timeline', + }), + ANOMALY_CHARTS: (chartsCount: number) => + i18n.translate('xpack.ml.cases.anomalyChartsTitle', { + defaultMessage: 'Anomaly {chartsCount, plural, one {chart} other {charts}}', + values: { + chartsCount, + }, + }), + SINGLE_METRIC_VIEWER: i18n.translate('xpack.ml.cases.singleMetricViewerTitle', { + defaultMessage: 'Single metric viewer', + }), };