[i18n] Translate missing labels in Home and Dashboard (#26958) (#27200)

* Add missing labels translations

* Update snapshot

* Fix issues
This commit is contained in:
Maryia Lapata 2018-12-14 17:09:46 +03:00 committed by Nox911
parent 9c8d75c94a
commit fe4f8498b4
8 changed files with 48 additions and 25 deletions

View file

@ -548,7 +548,11 @@ exports[`after fetch renders warning when listingLimit is exceeded 1`] = `
/> />
</EuiLink>, </EuiLink>,
"listingLimitText": <strong> "listingLimitText": <strong>
listingLimit <FormattedMessage
defaultMessage="listingLimit"
id="kbn.dashboard.listing.listingLimitExceededListingLimitTitle"
values={Object {}}
/>
</strong>, </strong>,
"listingLimitValue": 1, "listingLimitValue": 1,
"totalDashboards": 2, "totalDashboards": 2,

View file

@ -257,7 +257,10 @@ class DashboardListingUi extends React.Component {
listingLimitValue: this.props.listingLimit, listingLimitValue: this.props.listingLimit,
listingLimitText: ( listingLimitText: (
<strong> <strong>
listingLimit <FormattedMessage
id="kbn.dashboard.listing.listingLimitExceededListingLimitTitle"
defaultMessage="listingLimit"
/>
</strong> </strong>
), ),
advancedSettingsLink: ( advancedSettingsLink: (

View file

@ -35,9 +35,8 @@ exports[`isCloudEnabled is false should not render instruction toggle when ON_PR
/> />
</React.Fragment> </React.Fragment>
<div> <div>
<Introduction <InjectIntl(IntroductionUI)
description="tutorial used to drive jest tests" description="tutorial used to drive jest tests"
isBeta={false}
title="jest test tutorial" title="jest test tutorial"
/> />
<EuiSpacer <EuiSpacer
@ -117,10 +116,9 @@ exports[`isCloudEnabled is false should render ON_PREM instructions with instruc
/> />
</React.Fragment> </React.Fragment>
<div> <div>
<Introduction <InjectIntl(IntroductionUI)
description="tutorial used to drive jest tests" description="tutorial used to drive jest tests"
iconType="logoApache" iconType="logoApache"
isBeta={false}
title="jest test tutorial" title="jest test tutorial"
/> />
<EuiSpacer <EuiSpacer
@ -210,10 +208,9 @@ exports[`should not render breadcrumbs when K7 1`] = `
restrictWidth={false} restrictWidth={false}
> >
<div> <div>
<Introduction <InjectIntl(IntroductionUI)
description="tutorial used to drive jest tests" description="tutorial used to drive jest tests"
iconType="logoApache" iconType="logoApache"
isBeta={false}
title="jest test tutorial" title="jest test tutorial"
/> />
<EuiSpacer <EuiSpacer
@ -293,10 +290,9 @@ exports[`should render ELASTIC_CLOUD instructions when isCloudEnabled is true 1`
/> />
</React.Fragment> </React.Fragment>
<div> <div>
<Introduction <InjectIntl(IntroductionUI)
description="tutorial used to drive jest tests" description="tutorial used to drive jest tests"
iconType="logoApache" iconType="logoApache"
isBeta={false}
title="jest test tutorial" title="jest test tutorial"
/> />
<EuiSpacer <EuiSpacer

View file

@ -131,7 +131,12 @@ class InstructionSetUi extends React.Component {
case StatusCheckStates.ERROR: case StatusCheckStates.ERROR:
return 'danger'; return 'danger';
default: default:
throw new Error(`Unexpected status check state ${statusCheckState}`); throw new Error(this.props.intl.formatMessage({
id: 'kbn.home.tutorial.unexpectedStatusCheckStateErrorDescription',
defaultMessage: 'Unexpected status check state {statusCheckState}'
}, {
statusCheckState
}));
} }
} }

View file

@ -31,9 +31,9 @@ import {
EuiBetaBadge, EuiBetaBadge,
} from '@elastic/eui'; } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
export function Introduction({ description, previewUrl, title, exportedFieldsUrl, iconType, isBeta }) { function IntroductionUI({ description, previewUrl, title, exportedFieldsUrl, iconType, isBeta, intl }) {
let img; let img;
if (previewUrl) { if (previewUrl) {
img = ( img = (
@ -42,7 +42,10 @@ export function Introduction({ description, previewUrl, title, exportedFieldsUrl
hasShadow hasShadow
allowFullScreen allowFullScreen
fullScreenIconColor="dark" fullScreenIconColor="dark"
alt="screenshot of primary dashboard." alt={intl.formatMessage({
id: 'kbn.home.tutorial.introduction.imageAltDescription',
defaultMessage: 'screenshot of primary dashboard.'
})}
url={previewUrl} url={previewUrl}
/> />
); );
@ -75,7 +78,12 @@ export function Introduction({ description, previewUrl, title, exportedFieldsUrl
let betaBadge; let betaBadge;
if (isBeta) { if (isBeta) {
betaBadge = ( betaBadge = (
<EuiBetaBadge label="Beta" /> <EuiBetaBadge
label={intl.formatMessage({
id: 'kbn.home.tutorial.introduction.betaLabel',
defaultMessage: 'Beta'
})}
/>
); );
} }
return ( return (
@ -109,7 +117,7 @@ export function Introduction({ description, previewUrl, title, exportedFieldsUrl
); );
} }
Introduction.propTypes = { IntroductionUI.propTypes = {
description: PropTypes.string.isRequired, description: PropTypes.string.isRequired,
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
previewUrl: PropTypes.string, previewUrl: PropTypes.string,
@ -118,6 +126,8 @@ Introduction.propTypes = {
isBeta: PropTypes.bool, isBeta: PropTypes.bool,
}; };
Introduction.defaultProps = { IntroductionUI.defaultProps = {
isBeta: false isBeta: false
}; };
export const Introduction = injectI18n(IntroductionUI);

View file

@ -18,12 +18,12 @@
*/ */
import React from 'react'; import React from 'react';
import { shallow } from 'enzyme'; import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { Introduction } from './introduction'; import { Introduction } from './introduction';
test('render', () => { test('render', () => {
const component = shallow(<Introduction const component = shallowWithIntl(<Introduction.WrappedComponent
description="this is a great tutorial about..." description="this is a great tutorial about..."
title="Great tutorial" title="Great tutorial"
/>); />);
@ -32,7 +32,7 @@ test('render', () => {
describe('props', () => { describe('props', () => {
test('iconType', () => { test('iconType', () => {
const component = shallow(<Introduction const component = shallowWithIntl(<Introduction.WrappedComponent
description="this is a great tutorial about..." description="this is a great tutorial about..."
title="Great tutorial" title="Great tutorial"
iconType="logoElastic" iconType="logoElastic"
@ -41,7 +41,7 @@ describe('props', () => {
}); });
test('exportedFieldsUrl', () => { test('exportedFieldsUrl', () => {
const component = shallow(<Introduction const component = shallowWithIntl(<Introduction.WrappedComponent
description="this is a great tutorial about..." description="this is a great tutorial about..."
title="Great tutorial" title="Great tutorial"
exportedFieldsUrl="exported_fields_url" exportedFieldsUrl="exported_fields_url"
@ -50,7 +50,7 @@ describe('props', () => {
}); });
test('previewUrl', () => { test('previewUrl', () => {
const component = shallow(<Introduction const component = shallowWithIntl(<Introduction.WrappedComponent
description="this is a great tutorial about..." description="this is a great tutorial about..."
title="Great tutorial" title="Great tutorial"
previewUrl="preview_image_url" previewUrl="preview_image_url"
@ -59,7 +59,7 @@ describe('props', () => {
}); });
test('isBeta', () => { test('isBeta', () => {
const component = shallow(<Introduction const component = shallowWithIntl(<Introduction.WrappedComponent
description="this is a great tutorial about..." description="this is a great tutorial about..."
title="Great tutorial" title="Great tutorial"
isBeta={true} isBeta={true}

View file

@ -125,7 +125,12 @@ class TutorialUi extends React.Component {
case INSTRUCTIONS_TYPE.ON_PREM_ELASTIC_CLOUD: case INSTRUCTIONS_TYPE.ON_PREM_ELASTIC_CLOUD:
return this.state.tutorial.onPremElasticCloud; return this.state.tutorial.onPremElasticCloud;
default: default:
throw new Error(`Unhandled instruction type ${this.state.visibleInstructions}`); throw new Error(this.props.intl.formatMessage({
id: 'kbn.home.tutorial.unhandledInstructionTypeErrorDescription',
defaultMessage: 'Unhandled instruction type {visibleInstructions}'
}, {
visibleInstructions: this.state.visibleInstructions
}));
} }
}; };

View file

@ -218,7 +218,7 @@ class TutorialDirectoryUi extends React.Component {
<EuiTitle size="l"> <EuiTitle size="l">
<h1> <h1>
<FormattedMessage <FormattedMessage
id="kbn.home.tutorial.addDataTitle" id="kbn.home.tutorial.addDataToKibanaTitle"
defaultMessage="Add Data to Kibana" defaultMessage="Add Data to Kibana"
/> />
</h1> </h1>