Skip to content

Commit 4410598

Browse files
[6.x] Translations for Tag Cloud (#24065) (#24125)
* Translations for Tag Cloud (#24065) * Translate pie and vaslib_basic_options (#23761) (#24124) Translate pie and vislib_basic_options * [I18n] Add one-time binding to angularjs i18n (#23499) (#23965) * Add one-time binding to angularjs i18n * Add watcher for values property * Watch values field only if it is provided * Fix ci * Translations for Tag Cloud (#24065)
1 parent a9f7cfc commit 4410598

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

.i18nrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"markdownVis": "src/core_plugins/markdown_vis",
88
"metricVis": "src/core_plugins/metric_vis",
99
"statusPage": "src/core_plugins/status_page",
10+
"tagCloud": "src/core_plugins/tagcloud",
1011
"xpack.idxMgmt": "x-pack/plugins/index_management"
1112
},
1213
"exclude": [

src/core_plugins/tagcloud/public/feedback_message.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import React, { Component } from 'react';
21+
import { FormattedMessage } from '@kbn/i18n/react';
2122

2223
export class FeedbackMessage extends Component {
2324

@@ -30,10 +31,16 @@ export class FeedbackMessage extends Component {
3031
return (
3132
<div className="tagcloud-notifications" >
3233
<div className="tagcloud-truncated-message" style={{ display: this.state.shouldShowTruncate ? 'block' : 'none' }}>
33-
The number of tags has been truncated to avoid long draw times.
34+
<FormattedMessage
35+
id="tagCloud.feedbackMessage.truncatedTagsDescription"
36+
defaultMessage="The number of tags has been truncated to avoid long draw times."
37+
/>
3438
</div>
3539
<div className="tagcloud-incomplete-message" style={{ display: this.state.shouldShowIncomplete ? 'block' : 'none' }}>
36-
The container is too small to display the entire cloud. Tags might be cropped or omitted.
40+
<FormattedMessage
41+
id="tagCloud.feedbackMessage.tooSmallContainerDescription"
42+
defaultMessage="The container is too small to display the entire cloud. Tags might be cropped or omitted."
43+
/>
3744
</div>
3845
</div>
3946
);

src/core_plugins/tagcloud/public/tag_cloud_vis.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ import { TagCloudVisualization } from './tag_cloud_visualization';
2626
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
2727
import { Status } from 'ui/vis/update_status';
2828

29-
VisTypesRegistryProvider.register(function (Private) {
29+
VisTypesRegistryProvider.register(function (Private, i18n) {
3030

3131
const VisFactory = Private(VisFactoryProvider);
3232

3333
return VisFactory.createBaseVisualization({
3434
name: 'tagcloud',
35-
title: 'Tag Cloud',
35+
title: i18n('tagCloud.vis.tagCloudTitle', { defaultMessage: 'Tag Cloud' }),
3636
icon: 'visTagCloud',
37-
description: 'A group of words, sized according to their importance',
37+
description: i18n('tagCloud.vis.tagCloudDescription', {
38+
defaultMessage: 'A group of words, sized according to their importance'
39+
}),
3840
category: CATEGORY.OTHER,
3941
visConfig: {
4042
defaults: {
@@ -57,7 +59,7 @@ VisTypesRegistryProvider.register(function (Private) {
5759
{
5860
group: 'metrics',
5961
name: 'metric',
60-
title: 'Tag Size',
62+
title: i18n('tagCloud.vis.schemas.metricTitle', { defaultMessage: 'Tag Size' }),
6163
min: 1,
6264
max: 1,
6365
aggFilter: ['!std_dev', '!percentiles', '!percentile_ranks', '!derivative', '!geo_bounds', '!geo_centroid'],
@@ -69,7 +71,7 @@ VisTypesRegistryProvider.register(function (Private) {
6971
group: 'buckets',
7072
name: 'segment',
7173
icon: 'fa fa-cloud',
72-
title: 'Tags',
74+
title: i18n('tagCloud.vis.schemas.segmentTitle', { defaultMessage: 'Tags' }),
7375
min: 1,
7476
max: 1,
7577
aggFilter: ['terms', 'significant_terms']

src/core_plugins/tagcloud/public/tag_cloud_vis_params.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<div class="kuiSideBarSection">
22
<div class="form-group">
33
<div class="form-group">
4-
<label>Text Scale</label>
4+
<label i18n-id="tagCloud.visParams.textScaleLabel" i18n-default-message="Text Scale"></label>
55
<select class="form-control" ng-model="editorState.params.scale" ng-options="mode for mode in config.collections.scales"></select>
66
</div>
77
<div class="form-group">
8-
<label>Orientations</label>
8+
<label i18n-id="tagCloud.visParams.orientationsLabel" i18n-default-message="Orientations"></label>
99
<select class="form-control" ng-model="editorState.params.orientation" ng-options="mode for mode in config.collections.orientations"></select>
1010
</div>
1111
<div class="form-group">
12-
<label>Font Size</label>
12+
<label i18n-id="tagCloud.visParams.fontSizeLabel" i18n-default-message="Font Size"></label>
1313
<div class="tag-cloud-fontsize-slider"></div>
1414
<div class="kuiBar">
1515
<div class="kuiBarSection">
@@ -19,10 +19,10 @@
1919
max="{{editorState.params.maxFontSize}}"
2020
class="kuiTextInput tag-cloud-fontsize-slider__input"
2121
ng-model="editorState.params.minFontSize"
22-
aria-label="Minimum tag font size"
22+
aria-label="{{ ::'tagCloud.visParams.minFontSizeAriaLabel' | i18n: { defaultMessage: 'Minimum tag font size' } }}"
2323
aria-describedby="tagCloudFontSliderMinUnit"
2424
>
25-
<span id="tagCloudFontSliderMinUnit" aria-label="pixels">px</span>
25+
<span id="tagCloudFontSliderMinUnit" aria-label="{{ ::'tagCloud.visParams.minPixelsAriaLabel' | i18n: { defaultMessage: 'pixels' } }}">px</span>
2626
</div>
2727
<div class="kuiBarSection">
2828
<input
@@ -31,18 +31,18 @@
3131
max="100"
3232
class="kuiTextInput tag-cloud-fontsize-slider__input"
3333
ng-model="editorState.params.maxFontSize"
34-
aria-label="Maximum tag font size"
34+
aria-label="{{ ::'tagCloud.visParams.maxFontSizeAriaLabel' | i18n: { defaultMessage: 'Maximum tag font size' } }}"
3535
aria-describedby="tagCloudFontSliderMaxUnit"
3636
>
37-
<span id="tagCloudFontSliderMaxUnit" aria-label="pixels">px</span>
37+
<span id="tagCloudFontSliderMaxUnit" aria-label="{{ ::'tagCloud.visParams.maxPixelsAriaLabel' | i18n: { defaultMessage: 'pixels' } }}">px</span>
3838
</div>
3939
</div>
4040
</div>
4141
<div>
4242
<label>
4343
<input type="checkbox" value="{{hideLabel}}" ng-model="editorState.params.showLabel" name="showLabel"
4444
ng-checked="editorState.params.showLabel">
45-
Show Label
45+
<span i18n-id="tagCloud.visParams.showLabelToggleLabel" i18n-default-message="Show Label"></span>
4646
</label>
4747
</div>
4848
</div>

src/core_plugins/tagcloud/public/tag_cloud_visualization.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { take } from 'rxjs/operators';
2323
import { render, unmountComponentAtNode } from 'react-dom';
2424
import React from 'react';
2525

26-
26+
import { I18nProvider } from '@kbn/i18n/react';
2727
import { Label } from './label';
2828
import { FeedbackMessage } from './feedback_message';
2929

@@ -57,7 +57,7 @@ export class TagCloudVisualization {
5757
this._feedbackNode = document.createElement('div');
5858
this._containerNode.appendChild(this._feedbackNode);
5959
this._feedbackMessage = React.createRef();
60-
render(<FeedbackMessage ref={this._feedbackMessage} />, this._feedbackNode);
60+
render(<I18nProvider><FeedbackMessage ref={this._feedbackMessage} /></I18nProvider>, this._feedbackNode);
6161

6262
this._labelNode = document.createElement('div');
6363
this._containerNode.appendChild(this._labelNode);

0 commit comments

Comments
 (0)