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

[Canvas] i18n for page manager, page preview, and shape preview #46865

Merged
merged 7 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions x-pack/legacy/plugins/canvas/i18n/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,31 @@ export const ComponentStrings = {
defaultMessage: 'Closes keyboard shortcuts reference',
}),
},
PageManager: {
getPageNumberAriaLabel: (pageNumber: number) =>
i18n.translate('xpack.canvas.pageManager.pageNumberAriaLabel', {
defaultMessage: 'Load page number {pageNumber}',
values: {
pageNumber,
},
}),
},
PagePreviewPageControls: {
getClonePageAriaLabel: () =>
i18n.translate('xpack.canvas.pagePreviewPageControls.clonePageAriaLabel', {
defaultMessage: 'Clone page',
}),
getDeletePageAriaLabel: () =>
i18n.translate('xpack.canvas.pagePreviewPageControls.deletePageAriaLabel', {
defaultMessage: 'Delete page',
}),
},
ShapePreview: {
getShapeErrorMessage: () =>
i18n.translate('xpack.canvas.shapePreview.shapeErrorMessage', {
defaultMessage: 'An unexpected error occurred: the SVG was not parseable',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVG should be a constant?

}),
},
Toolbar: {
getEditorButtonLabel: () =>
i18n.translate('xpack.canvas.toolbar.editorButtonLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { ConfirmModal } from '../confirm_modal';
import { Link } from '../link';
import { PagePreview } from '../page_preview';

import { ComponentStrings } from '../../../i18n';

const { PageManager: strings } = ComponentStrings;

export class PageManager extends React.PureComponent {
static propTypes = {
isWriteable: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -154,7 +158,7 @@ export class PageManager extends React.PureComponent {
<Link
name="loadWorkpad"
params={{ id: workpadId, page: pageNumber }}
aria-label={`Load page number ${pageNumber}`}
aria-label={strings.getPageNumberAriaLabel(pageNumber)}
>
{Style.it(
workpadCSS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import React from 'react';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiFlexItem, EuiButtonIcon, EuiToolTip } from '@elastic/eui';

import { ComponentStrings } from '../../../i18n';

const { PagePreviewPageControls: strings } = ComponentStrings;

export const PageControls = ({ pageId, onDelete, onDuplicate }) => {
const handleDuplicate = ev => {
ev.preventDefault();
Expand All @@ -27,15 +31,19 @@ export const PageControls = ({ pageId, onDelete, onDuplicate }) => {
>
<EuiFlexItem grow={false}>
<EuiToolTip content="Clone">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This content prop probably needs to be translated as well while you're here. It's where the content of of tooltip popover thingy comes from

image

<EuiButtonIcon iconType="copy" aria-label="Clone page" onClick={handleDuplicate} />
<EuiButtonIcon
iconType="copy"
aria-label={strings.getClonePageAriaLabel()}
onClick={handleDuplicate}
/>
</EuiToolTip>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiToolTip content="Delete">
<EuiButtonIcon
color="danger"
iconType="trash"
aria-label="Delete Page"
aria-label={strings.getDeletePageAriaLabel()}
onClick={handleDelete}
/>
</EuiToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import React from 'react';
import PropTypes from 'prop-types';

import { ComponentStrings } from '../../../i18n';

const { ShapePreview: strings } = ComponentStrings;

interface Props {
shape?: string;
}
Expand All @@ -24,7 +28,7 @@ export const ShapePreview = ({ shape }: Props) => {
.item(0);

if (!shapeSvg) {
throw new Error('An unexpected error occurred: the SVG was not parseable');
throw new Error(strings.getShapeErrorMessage());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do error messages like this need to be translated?

}

shapeSvg.setAttribute('fill', 'none');
Expand Down