Skip to content

Commit ff8675d

Browse files
authored
[I18n] Translate Timelion (#23880)
* Add translations for timelion plugin * Fix bugs * Fix messages ids, resolve comments * Update translations * Refactor links messages * Fix values bug * Use template literals to avoid single quote escaping
1 parent 6d79657 commit ff8675d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1572
-513
lines changed

.i18nrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"paths": {
33
"common.ui": "src/ui",
44
"console": "src/core_plugins/console",
5-
"inputControl":"src/core_plugins/input_control_vis",
5+
"inputControl": "src/core_plugins/input_control_vis",
66
"kbn": "src/core_plugins/kibana",
77
"kbnVislibVisTypes": "src/core_plugins/kbn_vislib_vis_types",
88
"markdownVis": "src/core_plugins/markdown_vis",
@@ -12,6 +12,7 @@
1212
"regionMap": "src/core_plugins/region_map",
1313
"statusPage": "src/core_plugins/status_page",
1414
"tileMap": "src/core_plugins/tile_map",
15+
"timelion": "src/core_plugins/timelion",
1516
"tagCloud": "src/core_plugins/tagcloud",
1617
"xpack.grokDebugger": "x-pack/plugins/grokdebugger",
1718
"xpack.idxMgmt": "x-pack/plugins/index_management",

src/core_plugins/timelion/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export default function (kibana) {
103103
description: `<em>[experimental]</em> Your API key from www.quandl.com`,
104104
category: ['timelion'],
105105
}
106-
}
106+
},
107+
translations: [],
107108
},
108109
init: require('./init.js'),
109110
});

src/core_plugins/timelion/init.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919

20+
import { i18n } from '@kbn/i18n';
2021
import _ from 'lodash';
2122
import processFunctionDefinition from './server/lib/process_function_definition';
2223

@@ -33,7 +34,15 @@ export default function (server) {
3334
}
3435

3536
function getFunction(name) {
36-
if (!functions[name]) throw new Error ('No such function: ' + name);
37+
if (!functions[name]) {
38+
throw new Error(
39+
i18n.translate('timelion.noFunctionErrorMessage', {
40+
defaultMessage: 'No such function: {name}',
41+
values: { name },
42+
})
43+
);
44+
}
45+
3746
return functions[name];
3847
}
3948

src/core_plugins/timelion/public/app.js

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ app.controller('timelion', function (
9191
kbnUrl,
9292
Notifier,
9393
Private,
94+
i18n,
9495
) {
9596

9697
// Keeping this at app scope allows us to keep the current page when the user
@@ -114,55 +115,86 @@ app.controller('timelion', function (
114115

115116
$scope.topNavMenu = [{
116117
key: 'new',
117-
description: 'New Sheet',
118+
description: i18n('timelion.topNavMenu.newDescription', {
119+
defaultMessage: 'New Sheet',
120+
}),
118121
run: function () { kbnUrl.change('/'); },
119122
testId: 'timelionNewButton',
120123
}, {
121124
key: 'add',
122-
description: 'Add a chart',
125+
description: i18n('timelion.topNavMenu.addDescription', {
126+
defaultMessage: 'Add a chart',
127+
}),
123128
run: function () { $scope.newCell(); },
124129
testId: 'timelionAddChartButton',
125130
}, {
126131
key: 'save',
127-
description: 'Save Sheet',
132+
description: i18n('timelion.topNavMenu.saveDescription', {
133+
defaultMessage: 'Save Sheet',
134+
}),
128135
template: require('plugins/timelion/partials/save_sheet.html'),
129136
testId: 'timelionSaveButton',
130137
}, {
131138
key: 'delete',
132-
description: 'Delete current sheet',
139+
description: i18n('timelion.topNavMenu.deleteDescription', {
140+
defaultMessage: 'Delete current sheet',
141+
}),
133142
disableButton: function () {
134143
return !savedSheet.id;
135144
},
136145
run: function () {
137146
const title = savedSheet.title;
138147
function doDelete() {
139148
savedSheet.delete().then(() => {
140-
toastNotifications.addSuccess(`Deleted '${title}'`);
149+
toastNotifications.addSuccess(i18n(
150+
'timelion.topNavMenu.delete.modal.successNotificationText',
151+
{
152+
defaultMessage: `Deleted '{title}'`,
153+
values: { title },
154+
}
155+
));
141156
kbnUrl.change('/');
142157
}).catch(error => fatalError(error, location));
143158
}
144159

145160
const confirmModalOptions = {
146161
onConfirm: doDelete,
147-
confirmButtonText: 'Delete',
148-
title: `Delete Timelion sheet '${title}'?`
162+
confirmButtonText: i18n('timelion.topNavMenu.delete.modal.confirmButtonLabel', {
163+
defaultMessage: 'Delete',
164+
}),
165+
title: i18n('timelion.topNavMenu.delete.modalTitle', {
166+
defaultMessage: `Delete Timelion sheet '{title}'?`,
167+
values: { title }
168+
}),
149169
};
150-
confirmModal(`You can't recover deleted sheets.`, confirmModalOptions);
170+
171+
confirmModal(
172+
i18n('timelion.topNavMenu.delete.modal.warningText', {
173+
defaultMessage: `You can't recover deleted sheets.`,
174+
}),
175+
confirmModalOptions
176+
);
151177
},
152178
testId: 'timelionDeleteButton',
153179
}, {
154180
key: 'open',
155-
description: 'Open Sheet',
181+
description: i18n('timelion.topNavMenu.openDescription', {
182+
defaultMessage: 'Open Sheet',
183+
}),
156184
template: require('plugins/timelion/partials/load_sheet.html'),
157185
testId: 'timelionOpenButton',
158186
}, {
159187
key: 'options',
160-
description: 'Options',
188+
description: i18n('timelion.topNavMenu.optionsDescription', {
189+
defaultMessage: 'Options',
190+
}),
161191
template: require('plugins/timelion/partials/sheet_options.html'),
162192
testId: 'timelionOptionsButton',
163193
}, {
164194
key: 'help',
165-
description: 'Help',
195+
description: i18n('timelion.topNavMenu.helpDescription', {
196+
defaultMessage: 'Help',
197+
}),
166198
template: '<timelion-help></timelion-help>',
167199
testId: 'timelionDocsButton',
168200
}];
@@ -289,7 +321,13 @@ app.controller('timelion', function (
289321
savedSheet.timelion_rows = $scope.state.rows;
290322
savedSheet.save().then(function (id) {
291323
if (id) {
292-
toastNotifications.addSuccess(`Saved sheet '${savedSheet.title}'`);
324+
toastNotifications.addSuccess(
325+
i18n('timelion.saveSheet.successNotificationText', {
326+
defaultMessage: `Saved sheet '{title}'`,
327+
values: { title: savedSheet.title },
328+
})
329+
);
330+
293331
if (savedSheet.id !== $routeParams.id) {
294332
kbnUrl.change('/{{id}}', { id: savedSheet.id });
295333
}
@@ -307,7 +345,12 @@ app.controller('timelion', function (
307345
savedExpression.visState.title = title;
308346
savedExpression.save().then(function (id) {
309347
if (id) {
310-
toastNotifications.addSuccess(`Saved expression '${savedExpression.title}'`);
348+
toastNotifications.addSuccess(
349+
i18n('timelion.saveExpression.successNotificationText', {
350+
defaultMessage: `Saved expression '{title}'`,
351+
values: { title: savedExpression.title },
352+
}),
353+
);
311354
}
312355
});
313356
});

src/core_plugins/timelion/public/directives/cells/cells.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121
<button
2222
class="timCell__action"
2323
ng-click="removeCell($index)"
24-
tooltip="Remove"
24+
tooltip="{{ ::'timelion.cells.actions.removeTooltip' | i18n: { defaultMessage: 'Remove' } }}"
2525
tooltip-append-to-body="1"
26-
aria-label="Remove chart"
26+
aria-label="{{ ::'timelion.cells.actions.removeAriaLabel' | i18n: { defaultMessage: 'Remove chart' } }}"
2727
>
2828
<span class="fa fa-remove"></span>
2929
</button>
3030
<button
3131
class="timCell__action"
32-
tooltip="Drag to reorder"
32+
tooltip="{{ ::'timelion.cells.actions.reorderTooltip' | i18n: { defaultMessage: 'Drag to reorder' } }}"
3333
tooltip-append-to-body="1"
3434
sv-handle
35-
aria-label="Drag to reorder"
35+
aria-label="{{ ::'timelion.cells.actions.reorderAriaLabel' | i18n: { defaultMessage: 'Drag to reorder' } }}"
3636
tabindex="-1"
3737
>
3838
<span class="fa fa-arrows"></span>
3939
</button>
4040
<button
4141
class="timCell__action"
4242
ng-click="transient.fullscreen = true"
43-
tooltip="Full screen"
43+
tooltip="{{ ::'timelion.cells.actions.fullscreenTooltip' | i18n: { defaultMessage: 'Full screen' } }}"
4444
tooltip-append-to-body="1"
45-
aria-label="Full screen chart"
45+
aria-label="{{ ::'timelion.cells.actions.fullscreenAriaLabel' | i18n: { defaultMessage: 'Full screen chart' } }}"
4646
>
4747
<span class="fa fa-expand"></span>
4848
</button>

src/core_plugins/timelion/public/directives/chart/chart.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
import panelRegistryProvider from '../../lib/panel_registry';
2120

2221
require('ui/modules')
2322
.get('apps/timelion', [])
24-
.directive('chart', function (Private) {
23+
.directive('chart', function (Private, i18n) {
2524
return {
2625
restrict: 'A',
2726
scope: {
@@ -46,7 +45,12 @@ require('ui/modules')
4645
const panelSchema = panelRegistry.byName[seriesList.render.type];
4746

4847
if (!panelSchema) {
49-
$elem.text('No such panel type: ' + seriesList.render.type);
48+
$elem.text(
49+
i18n('timelion.chart.seriesList.noSchemaWarning', {
50+
defaultMessage: 'No such panel type: {renderType}',
51+
values: { renderType: seriesList.render.type },
52+
})
53+
);
5054
return;
5155
}
5256

src/core_plugins/timelion/public/directives/fullscreen/fullscreen.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<button
55
class="timCell__action"
66
ng-click="transient.fullscreen = false"
7-
tooltip="Exit full screen"
7+
tooltip="{{ ::'timelion.fullscreen.exitTooltip' | i18n: { defaultMessage: 'Exit full screen' } }}"
88
tooltip-append-to-body="1"
9-
aria-label="Exit full screen"
9+
aria-label="{{ ::'timelion.fullscreen.exitAriaLabel' | i18n: { defaultMessage: 'Exit full screen' } }}"
1010
>
1111
<span class="fa fa-compress"></span>
1212
</button>

src/core_plugins/timelion/public/directives/timelion_expression_input.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
role="textbox"
1414
rows="{{ rows }}"
1515
class="timExpressionInput kuiTextArea fullWidth"
16-
placeholder="Try a query with .es(*)"
16+
placeholder="{{ ::'timelion.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {esQuery}', values: { esQuery: '.es(*)' } } }}"
1717
ng-model="sheet"
1818
ng-focus="onFocusInput()"
1919
ng-keydown="onKeyDownInput($event)"
@@ -22,7 +22,7 @@
2222
ng-mousedown="onMouseDownInput()"
2323
ng-mouseup="onMouseUpInput()"
2424
ng-click="onClickExpression()"
25-
aria-label="Timelion expression"
25+
aria-label="{{ ::'timelion.expressionInputAriaLabel' | i18n: { defaultMessage: 'Timelion expression' } }}"
2626
aria-multiline="false"
2727
aria-autocomplete="list"
2828
aria-controls="timelionSuggestionList"

src/core_plugins/timelion/public/directives/timelion_expression_suggestions/timelion_expression_suggestions.html

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,27 @@
2626
<h4>
2727
<strong>.{{suggestion.name}}()</strong>
2828
<small id="timelionSuggestionDescription{{$index}}">
29-
{{suggestion.help}}
30-
{{suggestion.chainable ? '(Chainable)' : '(Data Source)'}}
29+
<span
30+
ng-if="suggestion.chainable"
31+
i18n-id="timelion.expressionSuggestions.func.description.chainableText"
32+
i18n-default-message="{help} (Chainable)"
33+
i18n-values="{ help: suggestion.help }"
34+
></span>
35+
<span
36+
ng-if="!suggestion.chainable"
37+
i18n-id="timelion.expressionSuggestions.func.description.dataSourceText"
38+
i18n-default-message="{help} (Data Source)"
39+
i18n-values="{ help: suggestion.help }"
40+
></span>
3141
</small>
3242
</h4>
3343

3444
<div ng-show="suggestion.args.length > (suggestion.chainable ? 1: 0)">
3545
<div ng-show="suggestions.length > 1">
36-
<strong>Arguments:</strong>
46+
<strong
47+
i18n-id="timelion.expressionSuggestions.arg.listTitle"
48+
i18n-default-message="Arguments:"
49+
></strong>
3750
<span ng-repeat="arg in suggestion.args" ng-hide="$index < 1 && suggestion.chainable">
3851
<strong>{{arg.name}}</strong>=(<em>{{arg.types.join(' | ')}}</em>)
3952
<em ng-show="!$last">,</em>
@@ -43,9 +56,21 @@ <h4>
4356
<div class="timSuggestions__details" ng-show="suggestions.length === 1">
4457
<table class="table table-striped table-condensed table-bordered">
4558
<thead>
46-
<th scope="col">Argument Name</th>
47-
<th scope="col">Accepted Types</th>
48-
<th scope="col">Information</th>
59+
<th
60+
scope="col"
61+
i18n-id="timelion.expressionSuggestions.arg.nameTitle"
62+
i18n-default-message="Argument Name"
63+
></th>
64+
<th
65+
scope="col"
66+
i18n-id="timelion.expressionSuggestions.arg.typesTitle"
67+
i18n-default-message="Accepted Types"
68+
></th>
69+
<th
70+
scope="col"
71+
i18n-id="timelion.expressionSuggestions.arg.infoTitle"
72+
i18n-default-message="Information"
73+
></th>
4974
</thead>
5075
<tr ng-repeat="arg in suggestion.args" ng-hide="$index < 1 && suggestion.chainable">
5176
<td>{{arg.name}}</td>

0 commit comments

Comments
 (0)