Skip to content

Commit

Permalink
[ML] Explain log rates spikes: Fix API messages translations. (#137589)…
Browse files Browse the repository at this point in the history
… (#137720)

Adds translations to API status messages to fix singular/plural issues with dynamic messages.

(cherry picked from commit ee6d469)

Co-authored-by: Walter Rafelsberger <[email protected]>
  • Loading branch information
kibanamachine and walterra authored Aug 1, 2022
1 parent ae9f244 commit 62dc715
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
60 changes: 46 additions & 14 deletions x-pack/plugins/aiops/server/routes/explain_log_rate_spikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { chunk } from 'lodash';

import { i18n } from '@kbn/i18n';
import { asyncForEach } from '@kbn/std';
import type { IRouter } from '@kbn/core/server';
import { KBN_FIELD_TYPES } from '@kbn/field-types';
Expand Down Expand Up @@ -81,7 +82,12 @@ export const defineExplainLogRateSpikesRoute = (
updateLoadingStateAction({
ccsWarning: false,
loaded,
loadingState: 'Loading field candidates.',
loadingState: i18n.translate(
'xpack.aiops.explainLogRateSpikes.loadingState.loadingFieldCandidates',
{
defaultMessage: 'Loading field candidates.',
}
),
})
);

Expand All @@ -104,7 +110,16 @@ export const defineExplainLogRateSpikesRoute = (
updateLoadingStateAction({
ccsWarning: false,
loaded,
loadingState: `Identified ${fieldCandidates.length} field candidates.`,
loadingState: i18n.translate(
'xpack.aiops.explainLogRateSpikes.loadingState.identifiedFieldCandidates',
{
defaultMessage:
'Identified {fieldCandidatesCount, plural, one {# field candidate} other {# field candidates}}.',
values: {
fieldCandidatesCount: fieldCandidates.length,
},
}
),
})
);

Expand Down Expand Up @@ -144,9 +159,16 @@ export const defineExplainLogRateSpikesRoute = (
updateLoadingStateAction({
ccsWarning: false,
loaded,
loadingState: `Identified ${
changePoints?.length ?? 0
} significant field/value pairs.`,
loadingState: i18n.translate(
'xpack.aiops.explainLogRateSpikes.loadingState.identifiedFieldValuePairs',
{
defaultMessage:
'Identified {fieldValuePairsCount, plural, one {# significant field/value pair} other {# significant field/value pairs}}.',
values: {
fieldValuePairsCount: changePoints?.length ?? 0,
},
}
),
})
);

Expand All @@ -157,14 +179,6 @@ export const defineExplainLogRateSpikesRoute = (
}

if (changePoints?.length === 0) {
push(
updateLoadingStateAction({
ccsWarning: false,
loaded: 1,
loadingState: `Done.`,
})
);

end();
return;
}
Expand Down Expand Up @@ -239,7 +253,12 @@ export const defineExplainLogRateSpikesRoute = (
updateLoadingStateAction({
ccsWarning: false,
loaded,
loadingState: `Loading histogram data.`,
loadingState: i18n.translate(
'xpack.aiops.explainLogRateSpikes.loadingState.loadingHistogramData',
{
defaultMessage: 'Loading histogram data.',
}
),
})
);
push(
Expand All @@ -255,6 +274,19 @@ export const defineExplainLogRateSpikesRoute = (
});
}

push(
updateLoadingStateAction({
ccsWarning: false,
loaded: 1,
loadingState: i18n.translate(
'xpack.aiops.explainLogRateSpikes.loadingState.doneMessage',
{
defaultMessage: 'Done.',
}
),
})
);

end();
})();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default ({ getService }: FtrProviderContext) => {
};

const expected = {
chunksLength: 12,
actionsLength: 11,
chunksLength: 13,
actionsLength: 12,
noIndexChunksLength: 4,
noIndexActionsLength: 3,
changePointFilter: 'add_change_points',
Expand Down

0 comments on commit 62dc715

Please sign in to comment.