Skip to content

Commit

Permalink
[i18n] Fix broken i18n messages (#185011)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Jun 7, 2024
1 parent 817842b commit ae1d883
Show file tree
Hide file tree
Showing 30 changed files with 142 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const AppLoadingPlaceholder: FC<{ showPlainSpinner: boolean }> = ({ showPlainSpi
size={'xxl'}
className="appContainer__loading"
data-test-subj="appContainer-loadingSpinner"
aria-label={i18n.translate('core.application.appContainer.loadingAriaLabel', {
aria-label={i18n.translate('core.application.appContainer.plainSpinner.loadingAriaLabel', {
defaultMessage: 'Loading application',
})}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const STATUS_LEVEL_LEGACY_ATTRS = deepFreeze<Record<string, LegacyStateAttr>>({
[ServiceStatusLevels.critical.toString()]: {
id: 'red',
state: 'red',
title: i18n.translate('core.status.redTitle', {
title: i18n.translate('core.status.critical.redTitle', {
defaultMessage: 'Red',
}),
icon: 'danger',
Expand All @@ -116,7 +116,7 @@ const STATUS_LEVEL_LEGACY_ATTRS = deepFreeze<Record<string, LegacyStateAttr>>({
[ServiceStatusLevels.unavailable.toString()]: {
id: 'red',
state: 'red',
title: i18n.translate('core.status.redTitle', {
title: i18n.translate('core.status.unavailable.redTitle', {
defaultMessage: 'Red',
}),
icon: 'danger',
Expand All @@ -126,7 +126,7 @@ const STATUS_LEVEL_LEGACY_ATTRS = deepFreeze<Record<string, LegacyStateAttr>>({
[ServiceStatusLevels.degraded.toString()]: {
id: 'yellow',
state: 'yellow',
title: i18n.translate('core.status.yellowTitle', {
title: i18n.translate('core.status.degraded.yellowTitle', {
defaultMessage: 'Yellow',
}),
icon: 'warning',
Expand All @@ -136,7 +136,7 @@ const STATUS_LEVEL_LEGACY_ATTRS = deepFreeze<Record<string, LegacyStateAttr>>({
[ServiceStatusLevels.available.toString()]: {
id: 'green',
state: 'green',
title: i18n.translate('core.status.greenTitle', {
title: i18n.translate('core.status.available.greenTitle', {
defaultMessage: 'Green',
}),
icon: 'success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function AiAssistantSelectionPage() {
<EuiCallOut
iconType="warning"
title={i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.thisFeatureIsDisabledCallOutLabel',
'aiAssistantManagementSelection.aiAssistantSelectionPage.observabilityAi.thisFeatureIsDisabledCallOutLabel',
{
defaultMessage:
'This feature is disabled. It can be enabled from Spaces > Features.',
Expand Down Expand Up @@ -124,7 +124,7 @@ export function AiAssistantSelectionPage() {
<EuiCallOut
iconType="warning"
title={i18n.translate(
'aiAssistantManagementSelection.aiAssistantSelectionPage.thisFeatureIsDisabledCallOutLabel',
'aiAssistantManagementSelection.aiAssistantSelectionPage.securityAi.thisFeatureIsDisabledCallOutLabel',
{
defaultMessage:
'This feature is disabled. It can be enabled from Spaces > Features.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ function EditorUI({ initialTextValue, setEditorInstance }: EditorProps) {
>
<EuiFlexItem>
<EuiToolTip
content={i18n.translate('console.sendRequestButtonTooltip', {
content={i18n.translate('console.sendRequestButtonTooltipContent', {
defaultMessage: 'Click to send request',
})}
>
<EuiLink
color="primary"
onClick={sendCurrentRequest}
data-test-subj="sendRequestButton"
aria-label={i18n.translate('console.sendRequestButtonTooltip', {
aria-label={i18n.translate('console.sendRequestButtonTooltipAriaLabel', {
defaultMessage: 'Click to send request',
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ export const MonacoEditor = ({ initialTextValue }: EditorProps) => {
>
<EuiFlexItem>
<EuiToolTip
content={i18n.translate('console.sendRequestButtonTooltip', {
content={i18n.translate('console.sendRequestButtonTooltipContent', {
defaultMessage: 'Click to send request',
})}
>
<EuiLink
color="primary"
onClick={sendRequestsCallback}
data-test-subj="sendRequestButton"
aria-label={i18n.translate('console.sendRequestButtonTooltip', {
aria-label={i18n.translate('console.sendRequestButtonTooltipAriaLabel', {
defaultMessage: 'Click to send request',
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,197 +6,115 @@
* Side Public License, v 1.
*/

import { i18n } from '@kbn/i18n';
import moment from 'moment';

import {
dayLabel,
hourLabel,
yearLabel,
minuteLabel,
secondLabel,
millisecondLabel,
infinityLabel,
monthLabel,
} from './i18n_messages';

export const boundsDescendingRaw = [
{
bound: Infinity,
interval: moment.duration(1, 'year'),
boundLabel: i18n.translate('data.search.timeBuckets.infinityLabel', {
defaultMessage: 'More than a year',
}),
intervalLabel: i18n.translate('data.search.timeBuckets.yearLabel', {
defaultMessage: 'a year',
}),
boundLabel: infinityLabel(),
intervalLabel: yearLabel(),
},
{
bound: moment.duration(1, 'year'),
interval: moment.duration(1, 'month'),
boundLabel: i18n.translate('data.search.timeBuckets.yearLabel', {
defaultMessage: 'a year',
}),
intervalLabel: i18n.translate('data.search.timeBuckets.monthLabel', {
defaultMessage: 'a month',
}),
boundLabel: yearLabel(),
intervalLabel: monthLabel(),
},
{
bound: moment.duration(3, 'week'),
interval: moment.duration(1, 'week'),
boundLabel: i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount: 21 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount: 7 },
}),
boundLabel: dayLabel(21),
intervalLabel: dayLabel(7),
},
{
bound: moment.duration(1, 'week'),
interval: moment.duration(1, 'd'),
boundLabel: i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount: 7 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount: 1 },
}),
boundLabel: dayLabel(7),
intervalLabel: dayLabel(1),
},
{
bound: moment.duration(24, 'hour'),
interval: moment.duration(12, 'hour'),
boundLabel: i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount: 1 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount: 12 },
}),
boundLabel: dayLabel(1),
intervalLabel: hourLabel(12),
},
{
bound: moment.duration(6, 'hour'),
interval: moment.duration(3, 'hour'),
boundLabel: i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount: 6 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount: 3 },
}),
boundLabel: hourLabel(6),
intervalLabel: hourLabel(3),
},
{
bound: moment.duration(2, 'hour'),
interval: moment.duration(1, 'hour'),
boundLabel: i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount: 2 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount: 1 },
}),
boundLabel: hourLabel(2),
intervalLabel: hourLabel(1),
},
{
bound: moment.duration(45, 'minute'),
interval: moment.duration(30, 'minute'),
boundLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 45 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 30 },
}),
boundLabel: minuteLabel(45),
intervalLabel: minuteLabel(30),
},
{
bound: moment.duration(20, 'minute'),
interval: moment.duration(10, 'minute'),
boundLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 20 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 10 },
}),
boundLabel: minuteLabel(20),
intervalLabel: minuteLabel(10),
},
{
bound: moment.duration(9, 'minute'),
interval: moment.duration(5, 'minute'),
boundLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 9 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 5 },
}),
boundLabel: minuteLabel(9),
intervalLabel: minuteLabel(5),
},
{
bound: moment.duration(3, 'minute'),
interval: moment.duration(1, 'minute'),
boundLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 3 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount: 1 },
}),
boundLabel: minuteLabel(3),
intervalLabel: minuteLabel(1),
},
{
bound: moment.duration(45, 'second'),
interval: moment.duration(30, 'second'),
boundLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 45 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 30 },
}),
boundLabel: secondLabel(45),
intervalLabel: secondLabel(30),
},
{
bound: moment.duration(15, 'second'),
interval: moment.duration(10, 'second'),
boundLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 15 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 10 },
}),
boundLabel: secondLabel(15),
intervalLabel: secondLabel(10),
},
{
bound: moment.duration(7.5, 'second'),
interval: moment.duration(5, 'second'),
boundLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 7.5 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 5 },
}),
boundLabel: secondLabel(7.5),
intervalLabel: secondLabel(5),
},
{
bound: moment.duration(5, 'second'),
interval: moment.duration(1, 'second'),
boundLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 5 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount: 1 },
}),
boundLabel: secondLabel(5),
intervalLabel: secondLabel(1),
},
{
bound: moment.duration(500, 'ms'),
interval: moment.duration(100, 'ms'),
boundLabel: i18n.translate('data.search.timeBuckets.millisecondLabel', {
defaultMessage: '{amount, plural, one {a millisecond} other {# milliseconds}}',
values: { amount: 500 },
}),
intervalLabel: i18n.translate('data.search.timeBuckets.millisecondLabel', {
defaultMessage: '{amount, plural, one {a millisecond} other {# milliseconds}}',
values: { amount: 100 },
}),
boundLabel: millisecondLabel(500),
intervalLabel: millisecondLabel(100),
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { i18n } from '@kbn/i18n';

export const dayLabel = (amount: number) =>
i18n.translate('data.search.timeBuckets.dayLabel', {
defaultMessage: '{amount, plural, one {a day} other {# days}}',
values: { amount },
});

export const hourLabel = (amount: number) =>
i18n.translate('data.search.timeBuckets.hourLabel', {
defaultMessage: '{amount, plural, one {an hour} other {# hours}}',
values: { amount },
});

export const yearLabel = () =>
i18n.translate('data.search.timeBuckets.yearLabel', {
defaultMessage: 'a year',
});

export const minuteLabel = (amount: number) =>
i18n.translate('data.search.timeBuckets.minuteLabel', {
defaultMessage: '{amount, plural, one {a minute} other {# minutes}}',
values: { amount },
});

export const secondLabel = (amount: number) =>
i18n.translate('data.search.timeBuckets.secondLabel', {
defaultMessage: '{amount, plural, one {a second} other {# seconds}}',
values: { amount },
});

export const millisecondLabel = (amount: number) =>
i18n.translate('data.search.timeBuckets.millisecondLabel', {
defaultMessage: '{amount, plural, one {a millisecond} other {# milliseconds}}',
values: { amount },
});

export const infinityLabel = () =>
i18n.translate('data.search.timeBuckets.infinityLabel', {
defaultMessage: 'More than a year',
});

export const monthLabel = () =>
i18n.translate('data.search.timeBuckets.monthLabel', {
defaultMessage: 'a month',
});
Loading

0 comments on commit ae1d883

Please sign in to comment.