Skip to content

Commit

Permalink
Add i18n translation support (opensearch-project#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
starcatter authored and zhongnansu committed Jun 12, 2021
1 parent d9ea6da commit 18cabce
Show file tree
Hide file tree
Showing 31 changed files with 3,109 additions and 527 deletions.
7 changes: 7 additions & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"paths": {
"opensearch.reports": "public"
},
"exclude": [],
"translations": ["translations/zh-CN.json", "translations/pl.json"]
}
4 changes: 3 additions & 1 deletion opensearch-dashboards-plugin-helpers.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"package.json",
"tsconfig.json",
"yarn.lock",
".i18nrc.json",
"common/**/*",
"public/**/*",
"server/**/*"
"server/**/*",
"translations/**/*"
]
}
26 changes: 21 additions & 5 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { Main } from './main/main';
import { ReportDetails } from './main/report_details/report_details';
import { ReportDefinitionDetails } from './main/report_definition_details/report_definition_details';
import { EditReportDefinition } from './report_definitions/edit/edit_report_definition';
import { i18n } from '@osd/i18n';

export interface CoreInterface {
http: CoreStart['http'];
Expand Down Expand Up @@ -93,7 +94,10 @@ export const ReportsDashboardsApp = ({
path="/report_details/:reportId"
render={(props) => (
<ReportDetails
title="Report Details"
title={i18n.translate(
'opensearch.reports.app.reportDetails',
{ defaultMessage: 'Report Details' }
)}
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
Expand All @@ -104,7 +108,10 @@ export const ReportsDashboardsApp = ({
path="/report_definition_details/:reportDefinitionId"
render={(props) => (
<ReportDefinitionDetails
title="Report Definition Details"
title={i18n.translate(
'opensearch.reports.app.reportDefinitionDetails',
{ defaultMessage: 'Report Definition Details' }
)}
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
Expand All @@ -115,7 +122,10 @@ export const ReportsDashboardsApp = ({
path="/create"
render={(props) => (
<CreateReport
title="Create Report"
title={i18n.translate(
'opensearch.reports.app.createReport',
{ defaultMessage: 'Create Report' }
)}
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
Expand All @@ -126,7 +136,10 @@ export const ReportsDashboardsApp = ({
path="/edit/:reportDefinitionId"
render={(props) => (
<EditReportDefinition
title="Edit Report Definition"
title={i18n.translate(
'opensearch.reports.app.editReportDefinition',
{ defaultMessage: 'Edit Report Definition' }
)}
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
Expand All @@ -137,7 +150,10 @@ export const ReportsDashboardsApp = ({
path="/"
render={(props) => (
<Main
title="Reporting Homepage"
title={i18n.translate(
'opensearch.reports.app.reportingHomepage',
{ defaultMessage: 'Reporting Homepage' }
)}
httpClient={http}
{...props}
setBreadcrumbs={chrome.setBreadcrumbs}
Expand Down
7 changes: 6 additions & 1 deletion public/components/context_menu/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/* eslint-disable no-restricted-globals */
import $ from 'jquery';
import dateMath from '@elastic/datemath';
import { i18n } from '@osd/i18n';
import { readStreamToFile } from '../main/main_utils';
import {
contextMenuCreateReportDefinition,
Expand Down Expand Up @@ -280,7 +281,11 @@ function locationHashChanged() {
return;
}
const menuItem = document.createElement('div');
menuItem.innerHTML = getMenuItem('Reporting');
menuItem.innerHTML = getMenuItem(
i18n.translate('opensearch.reports.menu.name', {
defaultMessage: 'Reporting',
})
);
navMenu[0].insertBefore(menuItem.children[0], navMenu[0].lastChild);
} catch (e) {
console.log(e);
Expand Down
Loading

0 comments on commit 18cabce

Please sign in to comment.