Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[I18n] Translate Timelion #23880

Merged
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"markdownVis": "src/core_plugins/markdown_vis",
"metricVis": "src/core_plugins/metric_vis",
"statusPage": "src/core_plugins/status_page",
"timelion": "src/core_plugins/timelion",
"xpack.idxMgmt": "x-pack/plugins/index_management"
},
"exclude": [
Expand Down
3 changes: 2 additions & 1 deletion src/core_plugins/timelion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export default function (kibana) {
description: `<em>[experimental]</em> Your API key from www.quandl.com`,
category: ['timelion'],
}
}
},
translations: [],
},
init: require('./init.js'),
});
Expand Down
11 changes: 10 additions & 1 deletion src/core_plugins/timelion/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import processFunctionDefinition from './server/lib/process_function_definition';

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

function getFunction(name) {
if (!functions[name]) throw new Error ('No such function: ' + name);
if (!functions[name]) {
throw new Error(
i18n.translate('timelion.noFunctionError', {
defaultMessage: 'No such function: {name}',
values: { name },
})
);
}

return functions[name];
}

Expand Down
69 changes: 56 additions & 13 deletions src/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ app.controller('timelion', function (
kbnUrl,
Notifier,
Private,
i18n,
) {

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

$scope.topNavMenu = [{
key: 'new',
description: 'New Sheet',
description: i18n('timelion.topNavMenu.new', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'New Sheet',
}),
run: function () { kbnUrl.change('/'); },
testId: 'timelionNewButton',
}, {
key: 'add',
description: 'Add a chart',
description: i18n('timelion.topNavMenu.add', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Add a chart',
}),
run: function () { $scope.newCell(); },
testId: 'timelionAddChartButton',
}, {
key: 'save',
description: 'Save Sheet',
description: i18n('timelion.topNavMenu.save', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Save Sheet',
}),
template: require('plugins/timelion/partials/save_sheet.html'),
testId: 'timelionSaveButton',
}, {
key: 'delete',
description: 'Delete current sheet',
description: i18n('timelion.topNavMenu.delete.description', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Delete current sheet',
}),
disableButton: function () {
return !savedSheet.id;
},
run: function () {
const title = savedSheet.title;
function doDelete() {
savedSheet.delete().then(() => {
toastNotifications.addSuccess(`Deleted '${title}'`);
toastNotifications.addSuccess(i18n(
'timelion.topNavMenu.delete.modal.successNotification',
{
defaultMessage: 'Deleted \'{title}\'',
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
values: { title },
}
));
kbnUrl.change('/');
}).catch(error => fatalError(error, location));
}

const confirmModalOptions = {
onConfirm: doDelete,
confirmButtonText: 'Delete',
title: `Delete Timelion sheet '${title}'?`
confirmButtonText: i18n('timelion.topNavMenu.delete.modal.confirmButtonText', {
defaultMessage: 'Delete',
}),
title: i18n('timelion.topNavMenu.delete.modal.title', {
defaultMessage: 'Delete Timelion sheet \'{title}\'?',
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
values: { title }
}),
};
confirmModal(`You can't recover deleted sheets.`, confirmModalOptions);

confirmModal(
i18n('timelion.topNavMenu.delete.modal.warning', {
defaultMessage: 'You can\'t recover deleted sheets.',
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
}),
confirmModalOptions
);
},
testId: 'timelionDeleteButton',
}, {
key: 'open',
description: 'Open Sheet',
description: i18n('timelion.topNavMenu.open', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Open Sheet',
}),
template: require('plugins/timelion/partials/load_sheet.html'),
testId: 'timelionOpenButton',
}, {
key: 'options',
description: 'Options',
description: i18n('timelion.topNavMenu.options', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Options',
}),
template: require('plugins/timelion/partials/sheet_options.html'),
testId: 'timelionOptionsButton',
}, {
key: 'help',
description: 'Help',
description: i18n('timelion.topNavMenu.help', {
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Help',
}),
template: '<timelion-help></timelion-help>',
testId: 'timelionDocsButton',
}];
Expand Down Expand Up @@ -289,7 +321,13 @@ app.controller('timelion', function (
savedSheet.timelion_rows = $scope.state.rows;
savedSheet.save().then(function (id) {
if (id) {
toastNotifications.addSuccess(`Saved sheet '${savedSheet.title}'`);
toastNotifications.addSuccess(
i18n('timelion.saveSheet.successNotification', {
defaultMessage: 'Saved sheet \'{title}\'',
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
values: { title: savedSheet.title },
})
);

if (savedSheet.id !== $routeParams.id) {
kbnUrl.change('/{{id}}', { id: savedSheet.id });
}
Expand All @@ -307,7 +345,12 @@ app.controller('timelion', function (
savedExpression.visState.title = title;
savedExpression.save().then(function (id) {
if (id) {
toastNotifications.addSuccess(`Saved expression '${savedExpression.title}'`);
toastNotifications.addSuccess(
i18n('timelion.saveExpression.successNotification', {
defaultMessage: 'Saved expression \'{title}\'',
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
values: { title: savedExpression.title },
}),
);
}
});
});
Expand Down
12 changes: 6 additions & 6 deletions src/core_plugins/timelion/public/directives/cells/cells.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@
<button
class="timCell__action"
ng-click="removeCell($index)"
tooltip="Remove"
tooltip="{{ ::'timelion.cells.actions.removeTooltip' | i18n: { defaultMessage: 'Remove' } }}"
tooltip-append-to-body="1"
aria-label="Remove chart"
aria-label="{{ ::'timelion.cells.actions.removeAriaLabel' | i18n: { defaultMessage: 'Remove chart' } }}"
>
<span class="fa fa-remove"></span>
</button>
<button
class="timCell__action"
tooltip="Drag to reorder"
tooltip="{{ ::'timelion.cells.actions.reorderTooltip' | i18n: { defaultMessage: 'Drag to reorder' } }}"
tooltip-append-to-body="1"
sv-handle
aria-label="Drag to reorder"
aria-label="{{ ::'timelion.cells.actions.reorderAriaLabel' | i18n: { defaultMessage: 'Drag to reorder' } }}"
tabindex="-1"
>
<span class="fa fa-arrows"></span>
</button>
<button
class="timCell__action"
ng-click="transient.fullscreen = true"
tooltip="Full screen"
tooltip="{{ ::'timelion.cells.actions.fullscreenTooltip' | i18n: { defaultMessage: 'Full screen' } }}"
tooltip-append-to-body="1"
aria-label="Full screen chart"
aria-label="{{ ::'timelion.cells.actions.fullscreenAriaLabel' | i18n: { defaultMessage: 'Full screen chart' } }}"
>
<span class="fa fa-expand"></span>
</button>
Expand Down
10 changes: 7 additions & 3 deletions src/core_plugins/timelion/public/directives/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/

import panelRegistryProvider from '../../lib/panel_registry';

require('ui/modules')
.get('apps/timelion', [])
.directive('chart', function (Private) {
.directive('chart', function (Private, i18n) {
return {
restrict: 'A',
scope: {
Expand All @@ -46,7 +45,12 @@ require('ui/modules')
const panelSchema = panelRegistry.byName[seriesList.render.type];

if (!panelSchema) {
$elem.text('No such panel type: ' + seriesList.render.type);
$elem.text(
i18n('timelion.chart.seriesList.noSchemaWarning', {
defaultMessage: 'No such panel type: {renderType}',
values: { renderType: seriesList.render.type },
})
);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<button
class="timCell__action"
ng-click="transient.fullscreen = false"
tooltip="Exit full screen"
tooltip="{{ ::'timelion.fullscreen.exitTooltip' | i18n: { defaultMessage: 'Exit full screen' } }}"
tooltip-append-to-body="1"
aria-label="Exit full screen"
aria-label="{{ ::'timelion.fullscreen.exitAriaLabel' | i18n: { defaultMessage: 'Exit full screen' } }}"
>
<span class="fa fa-compress"></span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
role="textbox"
rows="{{ rows }}"
class="timExpressionInput kuiTextArea fullWidth"
placeholder="Try a query with .es(*)"
placeholder="{{ ::'timelion.expressionInput.placeholder' | i18n: { defaultMessage: 'Try a query with {esQuery}', values: { esQuery: '.es(*)' } } }}"
ng-model="sheet"
ng-focus="onFocusInput()"
ng-keydown="onKeyDownInput($event)"
Expand All @@ -22,7 +22,7 @@
ng-mousedown="onMouseDownInput()"
ng-mouseup="onMouseUpInput()"
ng-click="onClickExpression()"
aria-label="Timelion expression"
aria-label="{{ ::'timelion.expressionInput.ariaLabel' | i18n: { defaultMessage: 'Timelion expression' } }}"
aria-multiline="false"
aria-autocomplete="list"
aria-controls="timelionSuggestionList"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,27 @@ export function ArgValueSuggestionsProvider(Private, indexPatterns) {
metric: async function (partial, functionArgs) {
if (!partial || !partial.includes(':')) {
return [
{ name: 'avg:' },
{ name: 'cardinality:' },
{ name: 'count' },
{ name: 'max:' },
{ name: 'min:' },
{ name: 'percentiles:' },
{ name: 'sum:' }
{
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
name: 'avg:',
},
{
name: 'cardinality:',
},
{
name: 'count',
},
{
name: 'max:',
},
{
name: 'min:',
},
{
name: 'percentiles:',
},
{
name: 'sum:',
},
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@
<h4>
<strong>.{{suggestion.name}}()</strong>
<small id="timelionSuggestionDescription{{$index}}">
{{suggestion.help}}
{{suggestion.chainable ? '(Chainable)' : '(Data Source)'}}
<span
ng-if="suggestion.chainable"
i18n-id="timelion.expressionSuggestions.func.description.chainable"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="{help} (Chainable)"
i18n-values="{ help: suggestion.help }"
></span>
<span
ng-if="!suggestion.chainable"
i18n-id="timelion.expressionSuggestions.func.description.dataSource"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="{help} (Data Source)"
i18n-values="{ help: suggestion.help }"
></span>
</small>
</h4>

<div ng-show="suggestion.args.length > (suggestion.chainable ? 1: 0)">
<div ng-show="suggestions.length > 1">
<strong>Arguments:</strong>
<strong
i18n-id="timelion.expressionSuggestions.arg.list"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="Arguments:"
></strong>
<span ng-repeat="arg in suggestion.args" ng-hide="$index < 1 && suggestion.chainable">
<strong>{{arg.name}}</strong>=(<em>{{arg.types.join(' | ')}}</em>)
<em ng-show="!$last">,</em>
Expand All @@ -43,9 +56,21 @@ <h4>
<div class="timSuggestions__details" ng-show="suggestions.length === 1">
<table class="table table-striped table-condensed table-bordered">
<thead>
<th scope="col">Argument Name</th>
<th scope="col">Accepted Types</th>
<th scope="col">Information</th>
<th
scope="col"
i18n-id="timelion.expressionSuggestions.arg.name"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="Argument Name"
></th>
<th
scope="col"
i18n-id="timelion.expressionSuggestions.arg.types"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="Accepted Types"
></th>
<th
scope="col"
i18n-id="timelion.expressionSuggestions.arg.info"
LeanidShutau marked this conversation as resolved.
Show resolved Hide resolved
i18n-default-message="Information"
></th>
</thead>
<tr ng-repeat="arg in suggestion.args" ng-hide="$index < 1 && suggestion.chainable">
<td>{{arg.name}}</td>
Expand Down
Loading