Fix i18n issues (#38169) (#38191)

This commit is contained in:
Jen Huang 2019-06-06 10:06:54 -07:00 committed by GitHub
parent 35afc0d1bd
commit 240d9a2067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 30 deletions

View file

@ -6,14 +6,12 @@
import { LICENSE_TYPE_BASIC, LicenseType } from '../../../common/constants';
import { RepositoryType } from './types';
const PLUGIN_NAME = 'Snapshot Repositories';
export const PLUGIN = {
ID: 'snapshot_restore',
MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC as LicenseType,
getI18nName: (translate: (key: string, config: object) => string): string => {
return translate('xpack.snapshotRestore.appName', {
defaultMessage: PLUGIN_NAME,
getI18nName: (i18n: any): string => {
return i18n.translate('xpack.snapshotRestore.appName', {
defaultMessage: 'Snapshot Repositories',
});
},
};

View file

@ -31,7 +31,7 @@ export function snapshotRestore(kibana: any) {
plugins.license.registerLicenseChecker(
server,
PLUGIN.ID,
PLUGIN.getI18nName(i18n.translate),
PLUGIN.getI18nName(i18n),
PLUGIN.MINIMUM_LICENSE_REQUIRED
);
},

View file

@ -53,10 +53,9 @@ const SnapshotDetailsUi: React.FunctionComponent<Props> = ({
onClose,
}) => {
const {
core: {
i18n: { FormattedMessage, translate },
},
core: { i18n },
} = useAppDependencies();
const { FormattedMessage } = i18n;
const { trackUiMetric } = uiMetricService;
const { error, data: snapshotDetails } = loadSnapshot(repositoryName, snapshotId);
@ -131,7 +130,7 @@ const SnapshotDetailsUi: React.FunctionComponent<Props> = ({
const errorObject = notFound
? {
data: {
error: translate('xpack.snapshotRestore.snapshotDetails.errorSnapshotNotFound', {
error: i18n.translate('xpack.snapshotRestore.snapshotDetails.errorSnapshotNotFound', {
defaultMessage: `Either the snapshot '{snapshotId}' doesn't exist in the repository '{repositoryName}' or the repository doesn't exist.`,
values: {
snapshotId,

View file

@ -17,45 +17,43 @@ interface Props {
export const SnapshotState: React.SFC<Props> = ({ state }) => {
const {
core: {
i18n: { translate },
},
core: { i18n },
} = useAppDependencies();
const stateMap: any = {
[SNAPSHOT_STATE.IN_PROGRESS]: {
icon: <EuiLoadingSpinner size="m" />,
label: translate('xpack.snapshotRestore.snapshotState.inProgressLabel', {
label: i18n.translate('xpack.snapshotRestore.snapshotState.inProgressLabel', {
defaultMessage: 'Taking snapshot…',
}),
},
[SNAPSHOT_STATE.SUCCESS]: {
icon: <EuiIcon color="success" type="check" />,
label: translate('xpack.snapshotRestore.snapshotState.inProgressLabel', {
label: i18n.translate('xpack.snapshotRestore.snapshotState.completeLabel', {
defaultMessage: 'Snapshot complete',
}),
},
[SNAPSHOT_STATE.FAILED]: {
icon: <EuiIcon color="danger" type="cross" />,
label: translate('xpack.snapshotRestore.snapshotState.failedLabel', {
label: i18n.translate('xpack.snapshotRestore.snapshotState.failedLabel', {
defaultMessage: 'Snapshot failed',
}),
},
[SNAPSHOT_STATE.PARTIAL]: {
icon: <EuiIcon color="warning" type="alert" />,
label: translate('xpack.snapshotRestore.snapshotState.partialLabel', {
label: i18n.translate('xpack.snapshotRestore.snapshotState.partialLabel', {
defaultMessage: 'Partial failure',
}),
tip: translate('xpack.snapshotRestore.snapshotState.partialTipDescription', {
tip: i18n.translate('xpack.snapshotRestore.snapshotState.partialTipDescription', {
defaultMessage: `Global cluster state was stored, but at least one shard wasn't stored successfully. See the 'Failed indices' tab.`,
}),
},
[SNAPSHOT_STATE.INCOMPATIBLE]: {
icon: <EuiIcon color="warning" type="alert" />,
label: translate('xpack.snapshotRestore.snapshotState.incompatibleLabel', {
label: i18n.translate('xpack.snapshotRestore.snapshotState.incompatibleLabel', {
defaultMessage: 'Incompatible version',
}),
tip: translate('xpack.snapshotRestore.snapshotState.partialTipDescription', {
tip: i18n.translate('xpack.snapshotRestore.snapshotState.incompatibleTipDescription', {
defaultMessage: `Snapshot was created with a version of Elasticsearch incompatible with the cluster's version.`,
}),
},

View file

@ -31,16 +31,15 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
repositoryFilter,
}) => {
const {
core: {
i18n: { FormattedMessage, translate },
},
core: { i18n },
} = useAppDependencies();
const { FormattedMessage } = i18n;
const { trackUiMetric } = uiMetricService;
const columns = [
{
field: 'snapshot',
name: translate('xpack.snapshotRestore.snapshotList.table.snapshotColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.snapshotColumnTitle', {
defaultMessage: 'Snapshot',
}),
truncateText: true,
@ -56,7 +55,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'repository',
name: translate('xpack.snapshotRestore.snapshotList.table.repositoryColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.repositoryColumnTitle', {
defaultMessage: 'Repository',
}),
truncateText: true,
@ -67,7 +66,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'startTimeInMillis',
name: translate('xpack.snapshotRestore.snapshotList.table.startTimeColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.startTimeColumnTitle', {
defaultMessage: 'Date created',
}),
truncateText: true,
@ -78,7 +77,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'durationInMillis',
name: translate('xpack.snapshotRestore.snapshotList.table.durationColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.durationColumnTitle', {
defaultMessage: 'Duration',
}),
truncateText: true,
@ -101,7 +100,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'indices',
name: translate('xpack.snapshotRestore.snapshotList.table.indicesColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.indicesColumnTitle', {
defaultMessage: 'Indices',
}),
truncateText: true,
@ -111,7 +110,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'shards.total',
name: translate('xpack.snapshotRestore.snapshotList.table.shardsColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.shardsColumnTitle', {
defaultMessage: 'Shards',
}),
truncateText: true,
@ -121,7 +120,7 @@ export const SnapshotTable: React.FunctionComponent<Props> = ({
},
{
field: 'shards.failed',
name: translate('xpack.snapshotRestore.snapshotList.table.failedShardsColumnTitle', {
name: i18n.translate('xpack.snapshotRestore.snapshotList.table.failedShardsColumnTitle', {
defaultMessage: 'Failed shards',
}),
truncateText: true,