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

Translations for Reporting plugin #22757

Merged
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
389e495
Translate Reporting
maryia-lapata Aug 30, 2018
5c6974f
Merge branch 'master' into feature/translations/reporting
maryia-lapata Sep 3, 2018
3fc0d30
Use i18n core
maryia-lapata Sep 4, 2018
730d0c4
Translate Reporting
maryia-lapata Sep 5, 2018
6e76e77
Merge branch 'master' into feature/translations/reporting
maryia-lapata Sep 6, 2018
b8b8fb0
Translate Reporting
maryia-lapata Sep 6, 2018
4f1652b
Refactoring
maryia-lapata Sep 6, 2018
aa52270
Add reporting to i18n config
maryia-lapata Sep 7, 2018
abf7349
Fix tooltip translation
maryia-lapata Sep 10, 2018
f6092ab
Merge branch 'master' into feature/translations/reporting
maryia-lapata Sep 11, 2018
3e98293
Apply formatting for html
maryia-lapata Sep 12, 2018
eb9b0a5
Merge remote-tracking branch 'remotes/origin/master' into feature/tra…
maryia-lapata Sep 13, 2018
8b01dfa
Translate label in TS files.
maryia-lapata Sep 13, 2018
7fb96b2
Merge branch 'master' into feature/translations/reporting
maryia-lapata Sep 20, 2018
9b052de
Reduce tag number
maryia-lapata Sep 21, 2018
41e728a
Rename ids
maryia-lapata Sep 21, 2018
2d00e85
Update snapshot
maryia-lapata Sep 21, 2018
0ac7fed
Revert changes for removing span
maryia-lapata Sep 28, 2018
6e11f48
Merge branch 'master' into feature/translations/reporting
maryia-lapata Sep 28, 2018
91ffb59
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 2, 2018
75176e8
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 3, 2018
7aa16a8
Add types
maryia-lapata Oct 5, 2018
086a230
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 5, 2018
ae80880
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 22, 2018
0f13af5
Translate statuses
maryia-lapata Oct 22, 2018
b529dda
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 23, 2018
736972b
Merge branch 'master' into feature/translations/reporting
maryia-lapata Oct 24, 2018
4712291
update translation of Reporting plugin
tibmt Oct 25, 2018
3bb3ff0
Merge branch 'master' into feature/translations/reporting
tibmt Oct 26, 2018
9c5b975
fix variable name
pavel06081991 Oct 26, 2018
ae9f396
Merge branch 'master' into feature/translations/reporting
tibmt Oct 26, 2018
063d9ea
fix constants names
pavel06081991 Oct 26, 2018
8659300
update reporting translation
tibmt Oct 26, 2018
b5ff8dd
Merge branch 'feature/translations/reporting' of github.com:maryia-la…
pavel06081991 Oct 26, 2018
434f836
Merge remote-tracking branch 'maryia/feature/translations/reporting' …
pavel06081991 Oct 26, 2018
3e4fc04
fix copyright
pavel06081991 Oct 29, 2018
f0feceb
Merge remote-tracking branch 'upstream/master' into feature/translati…
LeanidShutau Oct 30, 2018
9e6d950
Fix types/angular packages incompatibility
LeanidShutau Oct 30, 2018
8eb3831
Merge remote-tracking branch 'upstream/master' into feature/translati…
LeanidShutau Nov 1, 2018
6d002d2
Merge branch 'master' into feature/translations/reporting
pavel06081991 Nov 2, 2018
d1e3ed9
Merge branch 'master' into feature/translations/reporting
maryia-lapata Nov 2, 2018
400f252
Merge branch 'master' into feature/translations/reporting
pavel06081991 Nov 6, 2018
456ac17
Merge remote-tracking branch 'upstream/master' into feature/translati…
LeanidShutau Nov 6, 2018
cec501e
Merge branch 'master' into feature/translations/reporting
maryia-lapata Nov 13, 2018
e83852e
Update yarn.lock
maryia-lapata Nov 13, 2018
525acfb
Merge branch 'master' into feature/translations/reporting
maryia-lapata Nov 16, 2018
d3a5150
Merge branch 'master' into feature/translations/reporting
maryia-lapata Nov 23, 2018
771fdd0
Fix duplicated import
maryia-lapata Nov 23, 2018
2079139
Merge branch 'master' into feature/translations/reporting
maryia-lapata Dec 3, 2018
a6f2cf4
Fix CI
maryia-lapata Dec 3, 2018
a725450
Small adjustments
maryia-lapata Dec 3, 2018
ba061e7
Merge branch 'master' into feature/translations/reporting
maryia-lapata Dec 3, 2018
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
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"statusPage": "src/core_plugins/status_page",
"tagCloud": "src/core_plugins/tagcloud",
"xpack.idxMgmt": "x-pack/plugins/index_management",
"xpack.reporting": "x-pack/plugins/reporting",
"xpack.watcher": "x-pack/plugins/watcher"
},
"exclude": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
exports[`#start() renders the GlobalToastList into the targetDomElement param 1`] = `
Array [
Array [
<GlobalToastList
dismissToast={[Function]}
toasts$={
Observable {
"_isScalar": false,
"source": BehaviorSubject {
<I18nProvider>
<GlobalToastList
dismissToast={[Function]}
toasts$={
Observable {
"_isScalar": false,
"_value": Array [],
"closed": false,
"hasError": false,
"isStopped": false,
"observers": Array [],
"thrownError": null,
},
"source": BehaviorSubject {
"_isScalar": false,
"_value": Array [],
"closed": false,
"hasError": false,
"isStopped": false,
"observers": Array [],
"thrownError": null,
},
}
}
}
/>,
/>
</I18nProvider>,
<div
test="target-dom-element"
/>,
Expand Down
12 changes: 8 additions & 4 deletions src/core/public/notifications/toasts/toasts_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { Toast } from '@elastic/eui';
import { GlobalToastList } from './global_toast_list';
import { ToastsStartContract } from './toasts_start_contract';

import { I18nProvider } from '@kbn/i18n/react';

interface Params {
targetDomElement: HTMLElement;
}
Expand All @@ -35,10 +37,12 @@ export class ToastsService {
const toasts = new ToastsStartContract();

render(
<GlobalToastList
dismissToast={(toast: Toast) => toasts.remove(toast)}
toasts$={toasts.get$()}
/>,
<I18nProvider>
<GlobalToastList
dismissToast={(toast: Toast) => toasts.remove(toast)}
toasts$={toasts.get$()}
/>
</I18nProvider>,
this.params.targetDomElement
);

Expand Down
44 changes: 24 additions & 20 deletions src/ui/public/share/show_share_context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { ShareActionProvider } from './share_action';

import { EuiWrappingPopover } from '@elastic/eui';

import { I18nProvider } from '@kbn/i18n/react';

let isOpen = false;

const container = document.createElement('div');
Expand Down Expand Up @@ -69,26 +71,28 @@ export function showShareContextMenu({

document.body.appendChild(container);
const element = (
<EuiWrappingPopover
className="navbar__popover"
id="sharePopover"
button={anchorElement}
isOpen={true}
closePopover={onClose}
panelPaddingSize="none"
withTitle
>
<ShareContextMenu
allowEmbed={allowEmbed}
getUnhashableStates={getUnhashableStates}
objectId={objectId}
objectType={objectType}
shareContextMenuExtensions={shareContextMenuExtensions}
sharingData={sharingData}
isDirty={isDirty}
onClose={onClose}
/>
</EuiWrappingPopover>
<I18nProvider>
<EuiWrappingPopover
className="navbar__popover"
id="sharePopover"
button={anchorElement}
isOpen={true}
closePopover={onClose}
panelPaddingSize="none"
withTitle
>
<ShareContextMenu
allowEmbed={allowEmbed}
getUnhashableStates={getUnhashableStates}
objectId={objectId}
objectType={objectType}
shareContextMenuExtensions={shareContextMenuExtensions}
sharingData={sharingData}
isDirty={isDirty}
onClose={onClose}
/>
</EuiWrappingPopover>
</I18nProvider>
);
ReactDOM.render(element, container);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { oncePerServer } from '../../../server/lib/once_per_server';
import { createTaggedLogger } from '../../../server/lib/create_tagged_logger';
import { createGenerateCsv } from './lib/generate_csv';
import { fieldFormatMapFactory } from './lib/field_format_map';
import { i18n } from '@kbn/i18n';

function executeJobFn(server) {
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data');
Expand All @@ -33,9 +34,10 @@ function executeJobFn(server) {
try {
decryptedHeaders = await crypto.decrypt(serializedEncryptedHeaders);
} catch (e) {
throw new Error(
'Failed to decrypt report job data. Please ensure that xpack.reporting.encryptionKey is set and re-generate this report.'
);
throw new Error(i18n.translate('xpack.reporting.exportTypes.csv.executeJob.failedToDecryptReportJobDataErrorMessage', {
defaultMessage: 'Failed to decrypt report job data. Please ensure that {encryptionKey} is set and re-generate this report.',
values: { encryptionKey: 'xpack.reporting.encryptionKey' }
}));
}

const fakeRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/

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

async function parseResponse(request) {
const response = await request;
if (!response._scroll_id) {
throw new Error('Expected _scroll_id in the following Elasticsearch response: ' + JSON.stringify(response));
throw new Error(i18n.translate('xpack.reporting.exportTypes.csv.hitIterator.expectedScrollIdErrorMessage', {
defaultMessage: 'Expected {scrollId} in the following Elasticsearch response: {response}',
values: { response: JSON.stringify(response), scrollId: '_scroll_id' }
}));
}

if (!response.hits) {
throw new Error('Expected hits in the following Elasticsearch response: ' + JSON.stringify(response));
throw new Error(i18n.translate('xpack.reporting.exportTypes.csv.hitIterator.expectedHitsErrorMessage', {
defaultMessage: 'Expected {hits} in the following Elasticsearch response: {response}',
values: { response: JSON.stringify(response), hits: 'hits' }
}));
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import url from 'url';
import cookie from 'cookie';
import { getAbsoluteUrlFactory } from './get_absolute_url';
import { i18n } from '@kbn/i18n';
import { cryptoFactory } from '../../../../server/lib/crypto';

export function compatibilityShimFactory(server) {
Expand All @@ -18,7 +19,9 @@ export function compatibilityShimFactory(server) {
const decryptedHeaders = await crypto.decrypt(job.headers);
return decryptedHeaders;
} catch (err) {
throw new Error('Failed to decrypt report job data. Please re-generate this report.');
throw new Error(i18n.translate('xpack.reporting.exportTypes.printablePdf.compShim.failedToDecryptReportJobDataErrorMessage', {
defaultMessage: 'Failed to decrypt report job data. Please re-generate this report.'
}));
}
};

Expand All @@ -36,7 +39,10 @@ export function compatibilityShimFactory(server) {
return savedObject.url;
}

throw new Error(`Unable to generate report for url ${savedObject.url}, it's not a Kibana URL`);
throw new Error(i18n.translate('xpack.reporting.exportTypes.printablePdf.compShim.unableToGenerateReportErrorMessage', {
defaultMessage: 'Unable to generate report for url {savedObjUrl}, it\'s not a Kibana URL',
values: { savedObjUrl: savedObject.url }
}));
};

const getSerializedSession = async (decryptedHeaders, jobSession) => {
Expand All @@ -48,7 +54,9 @@ export function compatibilityShimFactory(server) {
try {
return await crypto.decrypt(jobSession);
} catch (err) {
throw new Error('Failed to decrypt report job data. Please re-generate this report.');
throw new Error(i18n.translate('xpack.reporting.exportTypes.printablePdf.compShim.failedToDecryptReportJobDataErrorMessage', {
defaultMessage: 'Failed to decrypt report job data. Please re-generate this report.'
}));
}
}

Expand All @@ -59,7 +67,9 @@ export function compatibilityShimFactory(server) {

const cookieName = server.plugins.security.getSessionCookieOptions().name;
if (!cookieName) {
throw new Error('Unable to determine the session cookie name');
throw new Error(i18n.translate('xpack.reporting.exportTypes.printablePdf.compShim.undeterminedSessionCookieNameErrorMessage', {
defaultMessage: 'Unable to determine the session cookie name'
}));
}

return cookies[cookieName];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import _ from 'lodash';
import concat from 'concat-stream';
import Printer from 'pdfmake';
import xRegExp from 'xregexp';
import { i18n } from '@kbn/i18n';

const assetPath = path.resolve(__dirname, 'assets');

Expand Down Expand Up @@ -131,7 +132,13 @@ class PdfMaker {
}

getBuffer() {
if (!this._pdfDoc) throw new Error('Document stream has not been generated');
if (!this._pdfDoc) {
throw new Error(
i18n.translate('xpack.reporting.exportTypes.printablePdf.documentStreamIsNotgeneratedErrorMessage', {
defaultMessage: 'Document stream has not been generated'
})
);
}
return new Promise((resolve, reject) => {
const concatStream = concat(function (pdfBuffer) {
resolve(pdfBuffer);
Expand All @@ -144,7 +151,13 @@ class PdfMaker {
}

getStream() {
if (!this._pdfDoc) throw new Error('Document stream has not been generated');
if (!this._pdfDoc) {
throw new Error(
i18n.translate('xpack.reporting.exportTypes.printablePdf.documentStreamIsNotgeneratedErrorMessage', {
defaultMessage: 'Document stream has not been generated'
})
);
}
this._pdfDoc.end();
return this._pdfDoc;
}
Expand Down Expand Up @@ -203,14 +216,19 @@ function getTemplate(layout, logo, title) {
image: logo || logoPath,
}, {
alignment: 'center',
text: 'Page ' + currentPage.toString() + ' of ' + pageCount,
text: i18n.translate('xpack.reporting.exportTypes.printablePdf.pagingDescription', {
defaultMessage: 'Page {currentPage} of {pageCount}',
values: { currentPage: currentPage.toString(), pageCount }
}),
style: {
color: '#aaa'
},
}, ''],
[
logo ? {
text: 'Powered by Elastic',
text: i18n.translate('xpack.reporting.exportTypes.printablePdf.logoDescription', {
defaultMessage: 'Powered by Elastic'
}),
fontSize: 10,
style: {
color: "#aaa"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import fs from 'fs';
import getPort from 'get-port';
import { promisify } from 'bluebird';
import { LevelLogger } from '../../../../server/lib/level_logger';
import { i18n } from '@kbn/i18n';

const fsp = {
readFile: promisify(fs.readFile, fs)
Expand Down Expand Up @@ -61,7 +62,9 @@ export function screenshotsObservableFactory(server) {

const waitForNotFoundError = async (browser) => {
await browser.waitForSelector(`.toast.alert.alert-danger`);
throw new Error('Reporting subject could not be loaded to take a screenshot.');
throw new Error(i18n.translate('xpack.reporting.exportTypes.printablePdf.screenshots.reportingSubjectCouldNotBeLoadedErrorMessage', {
defaultMessage: 'Reporting subject could not be loaded to take a screenshot.'
}));
};

const getNumberOfItems = async (browser, layout) => {
Expand Down
9 changes: 7 additions & 2 deletions x-pack/plugins/reporting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { PHANTOM, createBrowserDriverFactory, getDefaultBrowser, getDefaultChrom
import { logConfiguration } from './log_configuration';

import { getReportingUsageCollector } from './server/usage';
import { i18n } from '@kbn/i18n';

const kbToBase64Length = (kb) => {
return Math.floor((kb * 1024 * 8) / 6);
Expand Down Expand Up @@ -46,9 +47,13 @@ export const reporting = (kibana) => {
},
uiSettingDefaults: {
[UI_SETTINGS_CUSTOM_PDF_LOGO]: {
name: 'PDF footer image',
name: i18n.translate('xpack.reporting.pdfFooterImageLabel', {
defaultMessage: 'PDF footer image'
}),
value: null,
description: `Custom image to use in the PDF's footer`,
description: i18n.translate('xpack.reporting.pdfFooterImageDescription', {
defaultMessage: 'Custom image to use in the PDF\'s footer'
}),
type: 'image',
options: {
maxSize: {
Expand Down
21 changes: 17 additions & 4 deletions x-pack/plugins/reporting/public/components/report_error_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
*/

import { EuiButtonIcon, EuiCallOut, EuiPopover } from '@elastic/eui';
import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import React, { Component } from 'react';
import { JobContent, jobQueueClient } from '../lib/job_queue_client';

interface Props {
jobId: string;
intl: InjectedIntl;
}

interface State {
Expand All @@ -19,7 +21,7 @@ interface State {
error?: string;
}

export class ReportErrorButton extends Component<Props, State> {
class ReportErrorButtonUi extends Component<Props, State> {
private mounted?: boolean;

constructor(props: Props) {
Expand All @@ -28,7 +30,10 @@ export class ReportErrorButton extends Component<Props, State> {
this.state = {
isLoading: false,
isPopoverOpen: false,
calloutTitle: 'Unable to generate report',
calloutTitle: props.intl.formatMessage({
id: 'xpack.reporting.errorButton.unableToGenerateReportTitle',
defaultMessage: 'Unable to generate report',
}),
};
}

Expand All @@ -38,7 +43,10 @@ export class ReportErrorButton extends Component<Props, State> {
onClick={this.togglePopover}
iconType="alert"
color={'danger'}
aria-label="Show report error"
aria-label={this.props.intl.formatMessage({
id: 'xpack.reporting.errorButton.showReportErrorAriaLabel',
defaultMessage: 'Show report error',
})}
/>
);

Expand Down Expand Up @@ -90,10 +98,15 @@ export class ReportErrorButton extends Component<Props, State> {
if (this.mounted) {
this.setState({
isLoading: false,
calloutTitle: 'Unable to fetch report content',
calloutTitle: this.props.intl.formatMessage({
id: 'xpack.reporting.errorButton.unableToFetchReportContentTitle',
defaultMessage: 'Unable to fetch report content',
}),
error: kfetchError.message,
});
}
}
};
}

export const ReportErrorButton = injectI18n(ReportErrorButtonUi);
Loading