Skip to content

Commit

Permalink
[i18n] Translate untranslated labels (#26416)
Browse files Browse the repository at this point in the history
* Translate some missing translations

* Fix issues

* Add topNavMenu translations

* Fix issues

* Fix topNav

* Fix issues

* Fix issues

* Fix kbnTopNav test and parametrs description
  • Loading branch information
Nox911 authored and chrisronline committed Dec 12, 2018
1 parent 65824c3 commit 3ce9b6d
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 54 deletions.
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"xpack.rollupJobs": "x-pack/plugins/rollup",
"xpack.searchProfiler": "x-pack/plugins/searchprofiler",
"xpack.security": "x-pack/plugins/security",
"xpack.spaces": "x-pack/plugins/spaces",
"xpack.watcher": "x-pack/plugins/watcher"
},
"exclude": [
Expand Down
5 changes: 4 additions & 1 deletion src/legacy/core_plugins/console/public/hacks/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
*/

import { DevToolsRegistryProvider } from 'ui/registry/dev_tools';
import { i18n } from '@kbn/i18n';

DevToolsRegistryProvider.register(() => ({
order: 1,
name: 'console',
display: 'Console',
display: i18n.translate('console.consoleDisplayName', {
defaultMessage: 'Console'
}),
url: '#/dev_tools/console'
}));
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ export function SenseTopNavController(Private, i18n) {
const controller = new KbnTopNavController([
{
key: 'welcome',
label: i18n('console.topNav.welcomeTabLabel', {
defaultMessage: 'Welcome'
}),
hideButton: true,
template: `<sense-welcome></sense-welcome>`,
testId: 'consoleWelcomeButton',
},
{
key: 'history',
label: i18n('console.topNav.historyTabLabel', {
defaultMessage: 'History'
}),
description: i18n('console.topNav.historyTabDescription', {
defaultMessage: 'History',
}),
Expand All @@ -40,6 +46,9 @@ export function SenseTopNavController(Private, i18n) {
},
{
key: 'settings',
label: i18n('console.topNav.settingsTabLabel', {
defaultMessage: 'Settings'
}),
description: i18n('console.topNav.settingsTabDescription', {
defaultMessage: 'Settings',
}),
Expand All @@ -48,6 +57,9 @@ export function SenseTopNavController(Private, i18n) {
},
{
key: 'help',
label: i18n('console.topNav.helpTabLabel', {
defaultMessage: 'Help'
}),
description: i18n('console.topNav.helpTabDescription', {
defaultMessage: 'Help',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,19 @@ function discoverController(
};

$scope.topNavMenu = [{
key: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', {
defaultMessage: 'new',
key: 'new',
label: i18n('kbn.discover.localMenu.localMenu.newSearchTitle', {
defaultMessage: 'New',
}),
description: i18n('kbn.discover.localMenu.newSearchDescription', {
defaultMessage: 'New Search',
}),
run: function () { kbnUrl.change('/discover'); },
testId: 'discoverNewButton',
}, {
key: i18n('kbn.discover.localMenu.saveTitle', {
defaultMessage: 'save',
key: 'save',
label: i18n('kbn.discover.localMenu.saveTitle', {
defaultMessage: 'Save',
}),
description: i18n('kbn.discover.localMenu.saveSearchDescription', {
defaultMessage: 'Save Search',
Expand Down Expand Up @@ -248,8 +250,9 @@ function discoverController(
showSaveModal(saveModal);
}
}, {
key: i18n('kbn.discover.localMenu.openTitle', {
defaultMessage: 'open',
key: 'open',
label: i18n('kbn.discover.localMenu.openTitle', {
defaultMessage: 'Open',
}),
description: i18n('kbn.discover.localMenu.openSavedSearchDescription', {
defaultMessage: 'Open Saved Search',
Expand All @@ -263,8 +266,9 @@ function discoverController(
});
}
}, {
key: i18n('kbn.discover.localMenu.shareTitle', {
defaultMessage: 'share',
key: 'share',
label: i18n('kbn.discover.localMenu.shareTitle', {
defaultMessage: 'Share',
}),
description: i18n('kbn.discover.localMenu.shareSearchDescription', {
defaultMessage: 'Share Search',
Expand All @@ -287,8 +291,9 @@ function discoverController(
});
}
}, {
key: i18n('kbn.discover.localMenu.inspectTitle', {
defaultMessage: 'inspect',
key: 'inspect',
label: i18n('kbn.discover.localMenu.inspectTitle', {
defaultMessage: 'Inspect',
}),
description: i18n('kbn.discover.localMenu.openInspectorForSearchDescription', {
defaultMessage: 'Open Inspector for search',
Expand Down
35 changes: 21 additions & 14 deletions src/legacy/core_plugins/timelion/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,35 +123,39 @@ app.controller('timelion', function (
const savedSheet = $route.current.locals.savedSheet;

$scope.topNavMenu = [{
key: i18n('timelion.topNavMenu.newSheetButtonLabel', {
defaultMessage: 'new',
key: 'new',
label: i18n('timelion.topNavMenu.newSheetButtonLabel', {
defaultMessage: 'New',
}),
description: i18n('timelion.topNavMenu.newSheetButtonAriaLabel', {
defaultMessage: 'New Sheet',
}),
run: function () { kbnUrl.change('/'); },
testId: 'timelionNewButton',
}, {
key: i18n('timelion.topNavMenu.addChartButtonLabel', {
defaultMessage: 'add',
key: 'add',
label: i18n('timelion.topNavMenu.addChartButtonLabel', {
defaultMessage: 'Add',
}),
description: i18n('timelion.topNavMenu.addChartButtonAriaLabel', {
defaultMessage: 'Add a chart',
}),
run: function () { $scope.newCell(); },
testId: 'timelionAddChartButton',
}, {
key: i18n('timelion.topNavMenu.saveSheetButtonLabel', {
defaultMessage: 'save',
key: 'save',
label: i18n('timelion.topNavMenu.saveSheetButtonLabel', {
defaultMessage: 'Save',
}),
description: i18n('timelion.topNavMenu.saveSheetButtonAriaLabel', {
defaultMessage: 'Save Sheet',
}),
template: require('plugins/timelion/partials/save_sheet.html'),
testId: 'timelionSaveButton',
}, {
key: i18n('timelion.topNavMenu.deleteSheetButtonLabel', {
defaultMessage: 'delete',
key: 'delete',
label: i18n('timelion.topNavMenu.deleteSheetButtonLabel', {
defaultMessage: 'Delete',
}),
description: i18n('timelion.topNavMenu.deleteSheetButtonAriaLabel', {
defaultMessage: 'Delete current sheet',
Expand Down Expand Up @@ -194,26 +198,29 @@ app.controller('timelion', function (
},
testId: 'timelionDeleteButton',
}, {
key: i18n('timelion.topNavMenu.openSheetButtonLabel', {
defaultMessage: 'open',
key: 'open',
label: i18n('timelion.topNavMenu.openSheetButtonLabel', {
defaultMessage: 'Open',
}),
description: i18n('timelion.topNavMenu.openSheetButtonAriaLabel', {
defaultMessage: 'Open Sheet',
}),
template: require('plugins/timelion/partials/load_sheet.html'),
testId: 'timelionOpenButton',
}, {
key: i18n('timelion.topNavMenu.optionsButtonLabel', {
defaultMessage: 'options',
key: 'options',
label: i18n('timelion.topNavMenu.optionsButtonLabel', {
defaultMessage: 'Options',
}),
description: i18n('timelion.topNavMenu.optionsButtonAriaLabel', {
defaultMessage: 'Options',
}),
template: require('plugins/timelion/partials/sheet_options.html'),
testId: 'timelionOptionsButton',
}, {
key: i18n('timelion.topNavMenu.helpButtonLabel', {
defaultMessage: 'help',
key: 'help',
label: i18n('timelion.topNavMenu.helpButtonLabel', {
defaultMessage: 'Help',
}),
description: i18n('timelion.topNavMenu.helpButtonAriaLabel', {
defaultMessage: 'Help',
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/kbn_top_nav/__tests__/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ describe('KbnTopNavController', function () {
});

describe('description:', function () {
it('defaults to "Toggle ${key} view" when using templates', function () {
it('defaults to "Toggle ${label} view" when using templates', function () {
const controller = new KbnTopNavController([
{ key: 'foo', template: '<h1></h1>' },
{ key: 'Bar', description: 'not the default' },
{ key: '1234', run: ()=>{} },
]);

expect(pluck(controller.opts, 'description')).to.eql([
'Toggle foo view',
'Toggle Foo view',
'not the default',
'1234',
]);
Expand Down
6 changes: 5 additions & 1 deletion src/ui/public/kbn_top_nav/kbn_top_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
class="kuiLocalDropdown"
ng-show="kbnTopNav.rendered"
>
<button class="kuiLocalDropdownCloseButton" ng-click="kbnTopNav.close()" aria-label="Close">
<button
class="kuiLocalDropdownCloseButton"
ng-click="kbnTopNav.close()"
aria-label="{{ ::'common.ui.topNav.closeAriaLabel' | i18n: { defaultMessage: 'Close' } }}"
>
<span class="kuiIcon fa-chevron-circle-up"></span>
</button>
<div id="template_wrapper">
Expand Down
5 changes: 3 additions & 2 deletions src/ui/public/kbn_top_nav/kbn_top_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
* A configuration object for a top nav component.
* @typedef {Object} KbnTopNavConfig
* @type Object
* @property {string} key - A display string which will be shown in the top nav for this option.
* @property {string} key - identifier of menu item.
* @property {string} label - A display string which will be shown in the top nav for this option.
* @property {string} [description] - optional, used for the screen-reader description of this
* menu. Defaults to "Toggle ${key} view" for templated menu items and just "${key}" for
* menu. Defaults to "Toggle ${label} view" for templated menu items and just "${label}" for
* programmatic menu items
* @property {string} testId - for testing purposes, can be used to retrieve this item.
* @property {Object} [template] - an html template that will be shown when this item is clicked.
Expand Down
9 changes: 7 additions & 2 deletions src/ui/public/kbn_top_nav/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { capitalize, isArray, isFunction, get } from 'lodash';
import chrome from '../chrome';
import filterTemplate from '../chrome/config/filter.html';
import intervalTemplate from '../chrome/config/interval.html';
import { i18n } from '@kbn/i18n';

export function KbnTopNavControllerProvider($compile) {
return class KbnTopNavController {
Expand Down Expand Up @@ -88,10 +89,14 @@ export function KbnTopNavControllerProvider($compile) {
};
// apply the defaults to individual options
_applyOptDefault(opt = {}) {
const optLabel = opt.label ? opt.label : capitalize(opt.key);
const defaultedOpt = {
label: capitalize(opt.key),
label: optLabel,
hasFunction: !!opt.run,
description: opt.run ? opt.key : `Toggle ${opt.key} view`,
description: opt.run ? optLabel : i18n.translate('common.ui.topNav.toggleViewAriaLabel', {
defaultMessage: 'Toggle {optLabel} view',
values: { optLabel }
}),
run: (item) => this.toggle(item.key),
...opt
};
Expand Down
9 changes: 7 additions & 2 deletions src/ui/public/management/sections_register.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
*/

import { ManagementSection } from './section';
import { i18n } from '@kbn/i18n';

export const management = new ManagementSection('management', {
display: 'Management'
display: i18n.translate('common.ui.management.displayName', {
defaultMessage: 'Management'
})
});

management.register('data', {
display: 'Connect Data',
display: i18n.translate('common.ui.management.connectDataDisplayName', {
defaultMessage: 'Connect Data'
}),
order: 0
});

Expand Down
21 changes: 21 additions & 0 deletions x-pack/plugins/graph/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
$scope.topNavMenu = [];
$scope.topNavMenu.push({
key: 'new',
label: i18n('xpack.graph.topNavMenu.newWorkspaceLabel', {
defaultMessage: 'New',
}),
description: i18n('xpack.graph.topNavMenu.newWorkspaceAriaLabel', {
defaultMessage: 'New Workspace',
}),
Expand All @@ -775,6 +778,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
if (!$scope.allSavingDisabled) {
$scope.topNavMenu.push({
key: 'save',
label: i18n('xpack.graph.topNavMenu.saveWorkspace.enabledLabel', {
defaultMessage: 'Save',
}),
description: i18n('xpack.graph.topNavMenu.saveWorkspace.enabledAriaLabel', {
defaultMessage: 'Save Workspace',
}),
Expand All @@ -787,6 +793,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
}else {
$scope.topNavMenu.push({
key: 'save',
label: i18n('xpack.graph.topNavMenu.saveWorkspace.disabledLabel', {
defaultMessage: 'Save',
}),
description: i18n('xpack.graph.topNavMenu.saveWorkspace.disabledAriaLabel', {
defaultMessage: 'Save Workspace',
}),
Expand All @@ -798,6 +807,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
}
$scope.topNavMenu.push({
key: 'open',
label: i18n('xpack.graph.topNavMenu.loadWorkspaceLabel', {
defaultMessage: 'Open',
}),
description: i18n('xpack.graph.topNavMenu.loadWorkspaceAriaLabel', {
defaultMessage: 'Load Saved Workspace',
}),
Expand All @@ -812,6 +824,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
disableButton: function () {
return $route.current.locals === undefined || $route.current.locals.savedWorkspace === undefined;
},
label: i18n('xpack.graph.topNavMenu.deleteWorkspace.enabledLabel', {
defaultMessage: 'Delete',
}),
description: i18n('xpack.graph.topNavMenu.deleteWorkspace.enabledAriaLabel', {
defaultMessage: 'Delete Saved Workspace',
}),
Expand Down Expand Up @@ -850,6 +865,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
$scope.topNavMenu.push({
key: 'delete',
disableButton: true,
label: i18n('xpack.graph.topNavMenu.deleteWorkspace.disabledLabel', {
defaultMessage: 'Delete',
}),
description: i18n('xpack.graph.topNavMenu.deleteWorkspace.disabledAriaLabel', {
defaultMessage: 'Delete Saved Workspace',
}),
Expand All @@ -861,6 +879,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $http, kbnUrl, Private
$scope.topNavMenu.push({
key: 'settings',
disableButton: function () { return $scope.selectedIndex === null; },
label: i18n('xpack.graph.topNavMenu.settingsLabel', {
defaultMessage: 'Settings',
}),
description: i18n('xpack.graph.topNavMenu.settingsAriaLabel', {
defaultMessage: 'Settings',
}),
Expand Down
14 changes: 13 additions & 1 deletion x-pack/plugins/spaces/public/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
* you may not use this file except in compliance with the Elastic License.
*/

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

export const SPACES_FEATURE_DESCRIPTION = `Organize your dashboards and other saved objects into meaningful categories.`;
let spacesFeatureDescription: string;

export const getSpacesFeatureDescription = () => {
if (!spacesFeatureDescription) {
spacesFeatureDescription = i18n.translate('xpack.spaces.featureDescription', {
defaultMessage:
'Organize your dashboards and other saved objects into meaningful categories.',
});
}

return spacesFeatureDescription;
};

export const MANAGE_SPACES_URL = chrome.addBasePath(`/app/kibana#/management/spaces/list`);
Loading

0 comments on commit 3ce9b6d

Please sign in to comment.