[i18n] Translate untranslated labels (#26416) (#27016)

* Translate some missing translations

* Fix issues

* Add topNavMenu translations

* Fix issues

* Fix topNav

* Fix issues

* Fix issues

* Fix kbnTopNav test and parametrs description
This commit is contained in:
Maryia Lapata 2018-12-14 10:24:30 +03:00 committed by Nox911
parent b1d2a3d608
commit 631a093023
19 changed files with 149 additions and 54 deletions

View file

@ -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": [

View file

@ -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'
}));

View file

@ -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',
}),
@ -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',
}),
@ -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',
}),

View file

@ -193,8 +193,9 @@ 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',
@ -202,8 +203,9 @@ function discoverController(
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',
@ -239,8 +241,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',
@ -254,8 +257,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',
@ -278,8 +282,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',

View file

@ -114,8 +114,9 @@ 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',
@ -123,8 +124,9 @@ app.controller('timelion', function (
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',
@ -132,8 +134,9 @@ app.controller('timelion', function (
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',
@ -141,8 +144,9 @@ app.controller('timelion', function (
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',
@ -185,8 +189,9 @@ 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',
@ -194,8 +199,9 @@ app.controller('timelion', function (
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',
@ -203,8 +209,9 @@ app.controller('timelion', function (
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',

View file

@ -67,7 +67,7 @@ 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' },
@ -75,7 +75,7 @@ describe('KbnTopNavController', function () {
]);
expect(pluck(controller.opts, 'description')).to.eql([
'Toggle foo view',
'Toggle Foo view',
'not the default',
'1234',
]);

View file

@ -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">

View file

@ -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.

View file

@ -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 {
@ -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
};

View file

@ -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
});

View file

@ -759,6 +759,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
$scope.topNavMenu = [];
$scope.topNavMenu.push({
key: 'new',
label: i18n('xpack.graph.topNavMenu.newWorkspaceLabel', {
defaultMessage: 'New',
}),
description: i18n('xpack.graph.topNavMenu.newWorkspaceAriaLabel', {
defaultMessage: 'New Workspace',
}),
@ -770,6 +773,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
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',
}),
@ -782,6 +788,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
}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',
}),
@ -793,6 +802,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
}
$scope.topNavMenu.push({
key: 'open',
label: i18n('xpack.graph.topNavMenu.loadWorkspaceLabel', {
defaultMessage: 'Open',
}),
description: i18n('xpack.graph.topNavMenu.loadWorkspaceAriaLabel', {
defaultMessage: 'Load Saved Workspace',
}),
@ -807,6 +819,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
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',
}),
@ -845,6 +860,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
$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',
}),
@ -856,6 +874,9 @@ app.controller('graphuiPlugin', function ($scope, $route, $interval, $http, kbnU
$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',
}),

View file

@ -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`);

View file

@ -4,18 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import {
FeatureCatalogueCategory,
FeatureCatalogueRegistryProvider,
// @ts-ignore
} from 'ui/registry/feature_catalogue';
import { SPACES_FEATURE_DESCRIPTION } from './lib/constants';
import { getSpacesFeatureDescription } from './lib/constants';
FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'spaces',
title: 'Spaces',
description: SPACES_FEATURE_DESCRIPTION,
title: i18n.translate('xpack.spaces.spacesTitle', {
defaultMessage: 'Spaces',
}),
description: getSpacesFeatureDescription(),
icon: 'spacesApp',
path: '/app/kibana#/management/spaces/list',
showOnHomePage: true,

View file

@ -174,7 +174,14 @@ class ManageSpacePageUI extends Component<Props, State> {
<Fragment>
<EuiFlexGroup responsive={false}>
<EuiFlexItem grow={false}>
<EuiFormRow label="Avatar">
<EuiFormRow
label={
<FormattedMessage
id="xpack.spaces.management.manageSpacePage.avatarLabel"
defaultMessage="Avatar"
/>
}
>
<SpaceAvatar space={this.state.space} size="l" />
</EuiFormRow>
</EuiFlexItem>

View file

@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
import 'plugins/spaces/views/management/page_routes';
import React from 'react';
import {
@ -37,7 +38,9 @@ routes.defaults(/\/management/, {
kibanaSection.register(MANAGE_SPACES_KEY, {
name: 'spacesManagementLink',
order: 10,
display: 'Spaces',
display: i18n.translate('xpack.spaces.displayName', {
defaultMessage: 'Spaces',
}),
url: `#/management/spaces/list`,
});
}

View file

@ -8,7 +8,7 @@ import { EuiContextMenuPanel, EuiText } from '@elastic/eui';
import React, { SFC } from 'react';
import { UserProfile } from '../../../../../xpack_main/public/services/user_profile';
import { ManageSpacesButton } from '../../../components';
import { SPACES_FEATURE_DESCRIPTION } from '../../../lib/constants';
import { getSpacesFeatureDescription } from '../../../lib/constants';
interface Props {
userProfile: UserProfile;
@ -24,7 +24,7 @@ export const SpacesDescription: SFC<Props> = (props: Props) => {
return (
<EuiContextMenuPanel {...panelProps}>
<EuiText className="spcDescription__text">
<p>{SPACES_FEATURE_DESCRIPTION}</p>
<p>{getSpacesFeatureDescription()}</p>
</EuiText>
<div key="manageSpacesButton" className="spcDescription__manageButtonWrapper">
<ManageSpacesButton

View file

@ -5,7 +5,6 @@
*/
import { EuiAvatar, EuiPopover, PopoverAnchorPosition } from '@elastic/eui';
import { I18nProvider } from '@kbn/i18n/react';
import React, { Component, ComponentClass } from 'react';
import { UserProfile } from '../../../../xpack_main/public/services/user_profile';
import { Space } from '../../../common/model/space';
@ -71,14 +70,12 @@ export class NavControlPopover extends Component<Props, State> {
);
} else {
element = (
<I18nProvider>
<SpacesMenu
spaces={this.state.spaces}
onSelectSpace={this.onSelectSpace}
userProfile={this.props.userProfile}
onManageSpacesClick={this.toggleSpaceSelector}
/>
</I18nProvider>
<SpacesMenu
spaces={this.state.spaces}
onSelectSpace={this.onSelectSpace}
userProfile={this.props.userProfile}
onManageSpacesClick={this.toggleSpaceSelector}
/>
);
}

View file

@ -3,6 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { i18n } from '@kbn/i18n';
// @ts-ignore
import { getClient } from '../../../../server/lib/get_client_shield';
import { DEFAULT_SPACE_ID } from '../../common/constants';
@ -31,8 +33,12 @@ export async function createDefaultSpace(server: any) {
await savedObjectsRepository.create(
'space',
{
name: 'Default',
description: 'This is your default space!',
name: i18n.translate('xpack.spaces.defaultSpaceTitle', {
defaultMessage: 'Default',
}),
description: i18n.translate('xpack.spaces.defaultSpaceDescription', {
defaultMessage: 'This is your default space!',
}),
color: '#00bfb3',
_reserved: true,
},

View file

@ -7,12 +7,15 @@
import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
import { i18n } from '@kbn/i18n';
FeatureCatalogueRegistryProvider.register(() => {
return {
id: 'watcher',
title: 'Watcher',
description: 'Detect changes in your data by creating, managing, and monitoring alerts.',
description: i18n.translate('xpack.watcher.watcherDescription', {
defaultMessage: 'Detect changes in your data by creating, managing, and monitoring alerts.'
}),
icon: 'watchesApp',
path: '/app/kibana#/management/elasticsearch/watcher/watches',
showOnHomePage: true,