Skip to content

Commit 73567a2

Browse files
authored
[i18n] Translate kuery_autocomplete (#29162) (#29512)
* Translate kuery_autocomplete * Resolve review comments
1 parent 468eabb commit 73567a2

File tree

4 files changed

+98
-9
lines changed

4 files changed

+98
-9
lines changed

.i18nrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"xpack.idxMgmt": "x-pack/plugins/index_management",
2828
"xpack.indexLifecycleMgmt": "x-pack/plugins/index_lifecycle_management",
2929
"xpack.infra": "x-pack/plugins/infra",
30+
"xpack.kueryAutocomplete": "x-pack/plugins/kuery_autocomplete",
3031
"xpack.licenseMgmt": "x-pack/plugins/license_management",
3132
"xpack.ml": "x-pack/plugins/ml",
3233
"xpack.logstash": "x-pack/plugins/logstash",

x-pack/plugins/kuery_autocomplete/public/autocomplete_providers/conjunction.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,36 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { i18n } from '@kbn/i18n';
8+
79
const type = 'conjunction';
810

11+
const bothArgumentsText = i18n.translate('xpack.kueryAutocomplete.andOperatorDescription.bothArgumentsText', {
12+
defaultMessage: 'both arguments',
13+
description: 'Part of xpack.kueryAutocomplete.andOperatorDescription. Full text: "Requires both arguments to be true"'
14+
});
15+
const oneOrMoreArgumentsText = i18n.translate('xpack.kueryAutocomplete.orOperatorDescription.oneOrMoreArgumentsText', {
16+
defaultMessage: 'one or more arguments',
17+
description: 'Part of xpack.kueryAutocomplete.orOperatorDescription. Full text: "Requires one or more arguments to be true"'
18+
});
19+
920
const conjunctions = {
10-
and: `<p>Requires <span class="suggestionItem__callout">both arguments</span> to be true</p>`,
11-
or: `<p>Requires <span class="suggestionItem__callout">one or more arguments</span> to be true</p>`
21+
and: '<p>' +
22+
i18n.translate('xpack.kueryAutocomplete.andOperatorDescription', {
23+
defaultMessage: 'Requires {bothArguments} to be true',
24+
values: { bothArguments: `<span class="suggestionItem__callout">${bothArgumentsText}</span>` },
25+
description: 'Full text: "Requires both arguments to be true". See ' +
26+
'xpack.kueryAutocomplete.andOperatorDescription.bothArgumentsText for "both arguments" part.'
27+
}) +
28+
'</p>',
29+
or: '<p>' +
30+
i18n.translate('xpack.kueryAutocomplete.orOperatorDescription', {
31+
defaultMessage: 'Requires {oneOrMoreArguments} to be true',
32+
values: { oneOrMoreArguments: `<span class="suggestionItem__callout">${oneOrMoreArgumentsText}</span>` },
33+
description: 'Full text: "Requires one or more arguments to be true". See ' +
34+
'xpack.kueryAutocomplete.orOperatorDescription.oneOrMoreArgumentsText for "one or more arguments" part.'
35+
}) +
36+
'</p>'
1237
};
1338

1439
function getDescription(conjunction) {

x-pack/plugins/kuery_autocomplete/public/autocomplete_providers/field.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ import { escape, flatten } from 'lodash';
88
import { escapeKuery } from './escape_kuery';
99
import { sortPrefixFirst } from 'ui/utils/sort_prefix_first';
1010
import { isFilterable } from 'ui/index_patterns/static_utils';
11+
import { i18n } from '@kbn/i18n';
1112

1213

1314
const type = 'field';
1415

1516
function getDescription(fieldName) {
16-
return `<p>Filter results that contain <span class="suggestionItem__callout">${escape(fieldName)}</span></p>`;
17+
return '<p>' +
18+
i18n.translate('xpack.kueryAutocomplete.filterResultsDescription', {
19+
defaultMessage: 'Filter results that contain {fieldName}',
20+
values: { fieldName: `<span class="suggestionItem__callout">${escape(fieldName)}</span>` }
21+
}) +
22+
'</p>';
1723
}
1824

1925
export function getSuggestionsProvider({ indexPatterns }) {

x-pack/plugins/kuery_autocomplete/public/autocomplete_providers/operator.js

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,89 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { i18n } from '@kbn/i18n';
8+
79
import { flatten } from 'lodash';
810
const type = 'operator';
911

12+
const equalsText = i18n.translate('xpack.kueryAutocomplete.equalOperatorDescription.equalsText', {
13+
defaultMessage: 'equals',
14+
description: 'Part of xpack.kueryAutocomplete.equalOperatorDescription. Full text: "equals some value"'
15+
});
16+
const lessThanOrEqualToText = i18n.translate('xpack.kueryAutocomplete.lessThanOrEqualOperatorDescription.lessThanOrEqualToText', {
17+
defaultMessage: 'less than or equal to',
18+
description: 'Part of xpack.kueryAutocomplete.lessThanOrEqualOperatorDescription. Full text: "is less than or equal to some value"'
19+
});
20+
const greaterThanOrEqualToText = i18n.translate('xpack.kueryAutocomplete.greaterThanOrEqualOperatorDescription.greaterThanOrEqualToText', {
21+
defaultMessage: 'greater than or equal to',
22+
description: 'Part of xpack.kueryAutocomplete.greaterThanOrEqualOperatorDescription. Full text: "is greater than or equal to some value"'
23+
});
24+
const lessThanText = i18n.translate('xpack.kueryAutocomplete.lessThanOperatorDescription.lessThanText', {
25+
defaultMessage: 'less than',
26+
description: 'Part of xpack.kueryAutocomplete.lessThanOperatorDescription. Full text: "is less than some value"'
27+
});
28+
const greaterThanText = i18n.translate('xpack.kueryAutocomplete.greaterThanOperatorDescription.greaterThanText', {
29+
defaultMessage: 'greater than',
30+
description: 'Part of xpack.kueryAutocomplete.greaterThanOperatorDescription. Full text: "is greater than some value"'
31+
});
32+
const existsText = i18n.translate('xpack.kueryAutocomplete.existOperatorDescription.existsText', {
33+
defaultMessage: 'exists',
34+
description: 'Part of xpack.kueryAutocomplete.existOperatorDescription. Full text: "exists in any form"'
35+
});
36+
1037
const operators = {
1138
':': {
12-
description: '<span class="suggestionItem__callout">equals</span> some value',
39+
description: i18n.translate('xpack.kueryAutocomplete.equalOperatorDescription', {
40+
defaultMessage: '{equals} some value',
41+
values: { equals: `<span class="suggestionItem__callout">${equalsText}</span>` },
42+
description: 'Full text: "equals some value". See ' +
43+
'xpack.kueryAutocomplete.equalOperatorDescription.equalsText for "equals" part.'
44+
}),
1345
fieldTypes: ['string', 'number', 'date', 'ip', 'geo_point', 'geo_shape', 'boolean']
1446
},
1547
'<=': {
16-
description: 'is <span class="suggestionItem__callout">less than or equal to</span> some value',
48+
description: i18n.translate('xpack.kueryAutocomplete.lessThanOrEqualOperatorDescription', {
49+
defaultMessage: 'is {lessThanOrEqualTo} some value',
50+
values: { lessThanOrEqualTo: `<span class="suggestionItem__callout">${lessThanOrEqualToText}</span>` },
51+
description: 'Full text: "is less than or equal to some value". See ' +
52+
'xpack.kueryAutocomplete.lessThanOrEqualOperatorDescription.lessThanOrEqualToText for "less than or equal to" part.'
53+
}),
1754
fieldTypes: ['number', 'date', 'ip']
1855
},
1956
'>=': {
20-
description: 'is <span class="suggestionItem__callout">greater than or equal to</span> to some value',
57+
description: i18n.translate('xpack.kueryAutocomplete.greaterThanOrEqualOperatorDescription', {
58+
defaultMessage: 'is {greaterThanOrEqualTo} some value',
59+
values: { greaterThanOrEqualTo: `<span class="suggestionItem__callout">${greaterThanOrEqualToText}</span>` },
60+
description: 'Full text: "is greater than or equal to some value". See ' +
61+
'xpack.kueryAutocomplete.greaterThanOrEqualOperatorDescription.greaterThanOrEqualToText for "greater than or equal to" part.'
62+
}),
2163
fieldTypes: ['number', 'date', 'ip']
2264
},
2365
'<': {
24-
description: 'is <span class="suggestionItem__callout">less than</span> some value',
66+
description: i18n.translate('xpack.kueryAutocomplete.lessThanOperatorDescription', {
67+
defaultMessage: 'is {lessThan} some value',
68+
values: { lessThan: `<span class="suggestionItem__callout">${lessThanText}</span>` },
69+
description: 'Full text: "is less than some value". See ' +
70+
'xpack.kueryAutocomplete.lessThanOperatorDescription.lessThanText for "less than" part.'
71+
}),
2572
fieldTypes: ['number', 'date', 'ip']
2673
},
2774
'>': {
28-
description: 'is <span class="suggestionItem__callout">greater than</span> some value',
75+
description: i18n.translate('xpack.kueryAutocomplete.greaterThanOperatorDescription', {
76+
defaultMessage: 'is {greaterThan} some value',
77+
values: { greaterThan: `<span class="suggestionItem__callout">${greaterThanText}</span>` },
78+
description: 'Full text: "is greater than some value". See ' +
79+
'xpack.kueryAutocomplete.greaterThanOperatorDescription.greaterThanText for "greater than" part.'
80+
}),
2981
fieldTypes: ['number', 'date', 'ip']
3082
},
3183
':*': {
32-
description: '<span class="suggestionItem__callout">exists</span> in any form'
84+
description: i18n.translate('xpack.kueryAutocomplete.existOperatorDescription', {
85+
defaultMessage: '{exists} in any form',
86+
values: { exists: `<span class="suggestionItem__callout">${existsText}</span>` },
87+
description: 'Full text: "exists in any form". See ' +
88+
'xpack.kueryAutocomplete.existOperatorDescription.existsText for "exists" part.'
89+
})
3390
},
3491
};
3592

0 commit comments

Comments
 (0)