diff --git a/.eslintignore b/.eslintignore index 4dae1a36513ee..ceff2d9d22291 100644 --- a/.eslintignore +++ b/.eslintignore @@ -28,3 +28,4 @@ bower_components /x-pack/plugins/**/__tests__/fixtures/** **/*.js.snap !/.eslintrc.js + diff --git a/package.json b/package.json index 61b20ac8abe66..d3a9982c7b9d4 100644 --- a/package.json +++ b/package.json @@ -216,6 +216,7 @@ "whatwg-fetch": "^2.0.3", "wreck": "12.4.0", "x-pack": "link:x-pack", + "yarn": "^1.6.0", "yauzl": "2.7.0" }, "devDependencies": { @@ -313,6 +314,7 @@ "pixelmatch": "4.0.2", "prettier": "^1.12.1", "proxyquire": "1.7.11", + "react-intl": "^2.4.0", "simple-git": "1.37.0", "sinon": "^5.0.7", "source-map": "0.5.6", diff --git a/packages/kbn-i18n/guideline.md b/packages/kbn-i18n/guideline.md new file mode 100644 index 0000000000000..685afd5b7fd96 --- /dev/null +++ b/packages/kbn-i18n/guideline.md @@ -0,0 +1,233 @@ +# I18n Guideline + +## For Vendors + +#### Message types + +Each message id ends with a descriptive type. +
+The following types are supported: +- header +- label +- button +- dropDown +- placeholder +- tooltip +- aria +- errorMessage +- toggleSwitch + +There is one more complex case, when we have to divide a single expression into different labels. For example the message before translation likes like: + + ```js +

+ The following deprecated languages are in use: {deprecatedLangsInUse.join(', ')}. Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to Painless to avoid any problems. +

+ ``` + +This phrase contains a variable languages list and a link (``Painless``). For such cases we divide the message into two parts: the main message, which contains placeholders, and additioanl message, which represents inner meesage. +
+It is used the following id naming structure: +1) the main message id has the type on the second-to-last position, thereby identifying a divided phrase, and the last segment ``detail``. +```js +“kbn.management.indexPattern.edit.scripted.deprecationLang.label.detail”: "The following deprecated languages are in use: {deprecatedLangsInUse}. Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to {link} to avoid any problems." +``` +2) the inner message id has the type on the second-to-last position and the name of the variable from the placeholder in the main message (in this case ``link``) as the last segment. +```js + +“kbn.management.indexPattern.edit.scripted.deprecationLang.label.link”: “Painless” +``` + +#### Attribute with variables interpolation + +Messages can contain placeholders for embedding a value of a variable. For example: +```js +"kbn.management.indexPattern.edit.scripted.deleteField.label": "Delete scripted field '{fieldName}'?" +"kbn.management.indexPattern.edit.scripted.noField.label": "'{indexPatternTitle}' index pattern doesn't have a scripted field called '{fieldName}'" +``` +Mostly such placeholders have meaningful name according to the ontent. + +#### Pluralization + +## Best practices + + +#### Naming conversation + +- Message id should start from namespace. For example: + + ```js + "kbn.management.indexPattern.create.stepTime.options.pattern.header" + "common.ui.indexPattern.create.warning.label" + ``` + +- Use camelCase for naming segments. + +- Each message id should end with a type. For example: + + ```js + “kbn.management.indexPattern.edit.createIndex.button” + “kbn.management.indexPattern.edit.mappingConflict.header” + “kbn.management.indexPattern.edit.mappingConflict.label” + “kbn.management.indexPattern.edit.fields.filter.aria” + “kbn.management.indexPattern.edit.fields.filter.placeholder” + “kbn.management.indexPattern.edit.refresh.tooltip” + “kbn.management.indexPattern.edit.fields.allTypes.dropDown” + “kbn.management.indexPattern.create.includeSystemIndices.toggleSwitch” + “kbn.management.indexPattern.edit.wrongType.errorMessage” + “kbn.management.indexPattern.edit.scripted.table.name.description” + ``` + +- For complex messagges, that is divided into several, use the folllowing approach: + - the main message id should have the type on the second-to-last position, thereby identifying a divided phrase, and the last segment should be ``detail``, + - the inner message id should have the type on the second-to-last position and the name of the variable from the placeholder in the main message as the last segment. + + For example before the translation there was a message: + ```js + Success! + Your index pattern matches {exactMatchedIndices.length} {exactMatchedIndices.length > 1 ? 'indices' : 'index'}. + ``` + + After translation: + ```js + + + ), + strongIndices: ( + + + ) + }} + /> + ``` + + +#### Define type for message + +Each message id should ends with a type of the message. For example + +- for header: + + ```js +

+ +

+ ``` + +- for label: + + ```js + + + + ``` + +- for button: + + ```js + + + + + ``` + +- for dropDown: + + ```js + + ``` + +- for placeholder: + + ```js + + ``` + +- for `aria-label` attribute and tooltip + + ```js + + ``` + +- for errorMessage: + + ```js + errors.push( + intl.formatMessage( + { + id: 'kbn.management.indexPattern.create.step.invalidCharacters.errorMessage', + defaultMessage: 'An index pattern cannot contain spaces or the characters: {characterList}' + }, + { characterList } + )); + ``` + +- for toggleSwitch + + ```js + } + /> + ``` + + +#### Follow lint rules + +To follow `eslint` rules for long default messages use backslashes in interpolated string. + + ```js + + ``` + Please make sure that there are no spaces and tabs on the next line after backslash. + +#### Text with plurals + +The numeric input is mapped to a plural category, some subset of "zero", "one", "two", "few", "many", and "other" depending on the locale and the type of plural. There are languages with multiple plural forms (Language Plural Rules http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html). + +```js + +``` + +#### Unit tests diff --git a/packages/kbn-i18n/src/index.js~HEAD b/packages/kbn-i18n/src/index.js~HEAD new file mode 100644 index 0000000000000..08d979958ee77 --- /dev/null +++ b/packages/kbn-i18n/src/index.js~HEAD @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as i18nCore from './core/i18n'; +import * as loader from './core/loader'; +import * as angular from './angular'; +import * as react from './react'; + +export { formats } from './core/formats'; + +export const i18n = i18nCore; +export const i18nLoader = loader; +export const AngularI18n = angular; +export const ReactI18n = react; diff --git a/src/core_plugins/kibana/__tests__/intl_enzyme_test_helper.js b/src/core_plugins/kibana/__tests__/intl_enzyme_test_helper.js new file mode 100644 index 0000000000000..0c3fe1611e574 --- /dev/null +++ b/src/core_plugins/kibana/__tests__/intl_enzyme_test_helper.js @@ -0,0 +1,49 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Components using the react-intl module require access to the intl context. This is not available when mounting single components in Enzyme. + * These helper functions aim to address that and wrap a valid, English-locale intl context around them. + */ + +import React from 'react'; +import { ReactI18n } from '@kbn/i18n'; +const { IntlProvider, intlShape } = ReactI18n; +import { mount } from 'enzyme'; + +// Create the IntlProvider to retrieve context for wrapping around. +const intlProvider = new IntlProvider({ locale: 'en', messages: {} }, {}); + +const { intl } = intlProvider.getChildContext(); + +// When using React-Intl `injectIntl` on components, props.intl is required. +function nodeWithIntlProp(node) { + return React.cloneElement(node, { intl }); +} + +export function mountWithIntl(node, { context, childContextTypes, ...additionalOptions } = {}) { + return mount( + nodeWithIntlProp(node), + { + context: { ...context, intl }, + childContextTypes: { intl: intlShape, ...childContextTypes }, + ...additionalOptions + } + ); +} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap index 7ae0e5fb3918f..20ad21a8e2fc5 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/__tests__/__snapshots__/empty_state.test.js.snap @@ -32,7 +32,11 @@ exports[`EmptyState should render normally 1`] = ` } } > - Couldn't find any Elasticsearch data + @@ -43,27 +47,45 @@ exports[`EmptyState should render normally 1`] = ` grow={true} >

- - You'll need to index some data into Elasticsearch before you can create an index pattern. - -   - - Learn how - - or - - get started with some sample data sets. - + + + , + "learnHowLink": + + , + "needToIndex": + + , + } + } + />

- Check for new data + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js index 304f3875cc05e..062da0ef8bc9e 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/empty_state/empty_state.js @@ -32,6 +32,10 @@ import { EuiButton, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const EmptyState = ({ onRefresh, }) => ( @@ -40,27 +44,47 @@ export const EmptyState = ({ -

Couldn't find any Elasticsearch data

+

+ +

- - You'll need to index some data into Elasticsearch before you can create an index pattern. - -   - - Learn how - - {' or '} - - get started with some sample data sets. - + + + + ), + learnHowLink: ( + + + + ), + getStartedLink: ( + + + + ) + }} + />

@@ -73,7 +97,10 @@ export const EmptyState = ({ onClick={onRefresh} data-test-subj="refreshIndicesButton" > - Check for new data +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap index c4165aaf0290c..8fdac00ff5409 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/__tests__/__snapshots__/header.test.js.snap @@ -9,7 +9,11 @@ exports[`Header should render normally 1`] = ` size="m" >

- Create index pattern +

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

@@ -43,7 +51,13 @@ exports[`Header should render normally 1`] = ` > + } onChange={[Function]} /> @@ -63,7 +77,11 @@ exports[`Header should render without including system indices 1`] = ` size="m" >

- Create index pattern +

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

@@ -97,7 +119,13 @@ exports[`Header should render without including system indices 1`] = ` > + } onChange={[Function]} /> diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js index 7264c606ea158..494b94ee88c89 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/header/header.js @@ -29,6 +29,10 @@ import { EuiSwitch, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const Header = ({ isIncludingSystemIndices, onChangeIncludingSystemIndices, @@ -36,21 +40,33 @@ export const Header = ({
-

Create index pattern

+

+ +

+

- Kibana uses index patterns to retrieve data from Elasticsearch indices for things like visualizations. +

} checked={isIncludingSystemIndices} onChange={onChangeIncludingSystemIndices} /> diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap index fa1e23d09ccaf..78226ec8fc67c 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/__tests__/__snapshots__/loading_state.test.js.snap @@ -32,7 +32,11 @@ exports[`LoadingState should render normally 1`] = ` } } > - Checking for Elasticsearch data + @@ -65,7 +69,11 @@ exports[`LoadingState should render normally 1`] = ` grow={true} size="s" > - Reticulating splines... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js index 692f76cc29a2f..21816ec060467 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/loading_state/loading_state.js @@ -30,13 +30,22 @@ import { EuiTitle, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const LoadingState = () => ( -

Checking for Elasticsearch data

+

+ +

@@ -49,7 +58,10 @@ export const LoadingState = () => ( - Reticulating splines... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap index 6aafbb2efad43..cfc033f33b6cc 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/__tests__/__snapshots__/step_index_pattern.test.js.snap @@ -1,21 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StepIndexPattern renders errors when input is invalid 1`] = ` -
, |" - data-test-subj="createIndexPatternStep1Header" - errors={ - Array [ - "An index pattern cannot contain spaces or the characters: \\\\, /, ?, \\", <, >, |", - ] - } - goToNextStep={[Function]} - isInputInvalid={true} - isNextStepDisabled={true} - onQueryChanged={[Function]} - query="?" -/> -`; +exports[`StepIndexPattern renders errors when input is invalid 1`] = `null`; exports[`StepIndexPattern renders indices which match the initial query 1`] = ` ({ ensureMinimumTime: async (promises) => Array.isArray(promises) ? await Promise.all(promises) : await promises @@ -110,7 +111,13 @@ describe('StepIndexPattern', () => { }); it('disables the next step if the index pattern exists', async () => { - const component = createComponent(); + const component = mountWithIntl(); component.setState({ indexPatternExists: true }); expect(component.find('Header').prop('isNextStepDisabled')).toBe(true); }); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap index e8f55b9c86dee..2d1997b46ed42 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/__tests__/__snapshots__/header.test.js.snap @@ -6,7 +6,11 @@ exports[`Header should mark the input as invalid 1`] = ` size="s" >

- Step 1 of 2: Define index pattern +

- You can use a - - * - - as a wildcard in your index pattern. + + * + , + } + } + />

- You can't use spaces or the characters - - % - - . + + % + , + } + } + />

} isInvalid={true} - label="Index pattern" + label={ + + } > - + @@ -86,7 +98,11 @@ exports[`Header should mark the input as invalid 1`] = ` onClick={[Function]} type="button" > - Next step +
@@ -99,7 +115,11 @@ exports[`Header should render normally 1`] = ` size="s" >

- Step 1 of 2: Define index pattern +

- You can use a - - * - - as a wildcard in your index pattern. + + * + , + } + } + />

- You can't use spaces or the characters - - % - - . + + % + , + } + } + />

} isInvalid={false} - label="Index pattern" + label={ + + } > - + @@ -175,7 +203,11 @@ exports[`Header should render normally 1`] = ` onClick={[Function]} type="button" > - Next step +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js index 68914fcfd0a3a..f7a15c788e667 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/header/header.js @@ -30,6 +30,10 @@ import { EuiFieldText, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { I18nContext, FormattedMessage } = ReactI18n; + export const Header = ({ isInputInvalid, errors, @@ -43,7 +47,10 @@ export const Header = ({

- Step 1 of 2: Define index pattern +

@@ -53,24 +60,45 @@ export const Header = ({ isInvalid={isInputInvalid} > } isInvalid={isInputInvalid} error={errors} helpText={
-

You can use a * as a wildcard in your index pattern.

-

You can't use spaces or the characters {characterList}.

+

+ * }} + /> +

+

+ {characterList} }} + /> +

} > - + + {intl => ( + + )} +
@@ -81,9 +109,13 @@ export const Header = ({ isDisabled={isNextStepDisabled} data-test-subj="createIndexPatternGoToStep2Button" > - Next step +
); + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap index b0d1d6396047f..5e3e47c27eb84 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/__tests__/__snapshots__/indices_list.test.js.snap @@ -55,8 +55,15 @@ exports[`IndicesList should change pages 1`] = ` size="s" type="button" > - Rows per page: - 1 + } closePopover={[Function]} @@ -152,8 +159,15 @@ exports[`IndicesList should change per page 1`] = ` size="s" type="button" > - Rows per page: - 1 + } closePopover={[Function]} @@ -274,8 +288,15 @@ exports[`IndicesList should highlight the query in the matches 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} @@ -381,8 +402,15 @@ exports[`IndicesList should render normally 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} @@ -568,8 +596,15 @@ exports[`IndicesList updating props should render all new indices 1`] = ` size="s" type="button" > - Rows per page: - 10 + } closePopover={[Function]} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js index f04de5d2fe80c..0108ea7b9052f 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/indices_list/indices_list.js @@ -40,6 +40,10 @@ import { Pager } from '@elastic/eui/lib/services'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export class IndicesList extends Component { static propTypes = { indices: PropTypes.array.isRequired, @@ -98,7 +102,11 @@ export class IndicesList extends Component { iconSide="right" onClick={this.openPerPageControl} > - Rows per page: {perPage} + ); diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap index 4a46466cad4c1..e37e322562d75 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/__tests__/__snapshots__/loading_indices.test.js.snap @@ -28,7 +28,11 @@ exports[`LoadingIndices should render normally 1`] = ` - Looking for matching indices... + - Just a sec... + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js index dfbe4fea78bc2..9ebbf1eab7b3d 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/loading_indices/loading_indices.js @@ -27,6 +27,10 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const LoadingIndices = ({ ...rest }) => ( ( - Looking for matching indices... + - Just a sec... + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap index d7cbca24bbc5a..e0690d23d0bcf 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__tests__/__snapshots__/status_message.test.js.snap @@ -14,16 +14,32 @@ exports[`StatusMessage should render with exact matches 1`] = ` />   - - Success! - -   Your index pattern matches - - 1 - - index - - . + + + , + "strongSuccess": + + , + } + } + /> @@ -38,12 +54,25 @@ exports[`StatusMessage should render with no partial matches 1`] = ` color="default" > - The index pattern you've entered doesn't match any indices. You can match any of your - - 2 - indices - - , below. + + + , + } + } + /> @@ -58,15 +87,26 @@ exports[`StatusMessage should render with partial matches 1`] = ` color="default" > - Your index pattern doesn't match any indices, but you have  - - 1 - - index - - which - looks - similar. + + + , + } + } + /> @@ -81,12 +121,25 @@ exports[`StatusMessage should render without a query 1`] = ` color="default" > - Your index pattern can match any of your - - 2 - indices - - , below. + + + , + } + } + /> @@ -101,7 +154,11 @@ exports[`StatusMessage should show that no indices exist 1`] = ` color="default" > - No Elasticsearch indices match your pattern. + @@ -116,7 +173,11 @@ exports[`StatusMessage should show that system indices exist 1`] = ` color="default" > - No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right. + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js index 4bd24c0c07b0d..b2440eef30494 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js @@ -25,6 +25,10 @@ import { EuiIcon, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const StatusMessage = ({ matchedIndices: { allIndices = [], @@ -45,14 +49,28 @@ export const StatusMessage = ({ if (allIndices.length > 1) { statusMessage = ( - Your index pattern can match any of your {allIndices.length} indices, below. + + ) }} + /> ); } else if (!isIncludingSystemIndices) { statusMessage = ( - No Elasticsearch indices match your pattern. To view the matching system indices, toggle the switch in the upper right. + ); } @@ -60,7 +78,10 @@ export const StatusMessage = ({ // This should never really happen but let's handle it just in case statusMessage = ( - No Elasticsearch indices match your pattern. + ); } @@ -71,9 +92,27 @@ export const StatusMessage = ({ statusMessage = (   - Success! -   - Your index pattern matches {exactMatchedIndices.length} {exactMatchedIndices.length > 1 ? 'indices' : 'index'}. + + + ), + strongIndices: ( + + + ) + }} + /> ); } @@ -82,11 +121,21 @@ export const StatusMessage = ({ statusColor = 'default'; statusMessage = ( - Your index pattern doesn't match any indices, but you have  - - {partialMatchedIndices.length} {partialMatchedIndices.length > 1 ? 'indices ' : 'index '} - - which {partialMatchedIndices.length > 1 ? 'look' : 'looks'} similar. + + ) + }} + /> ); } @@ -95,8 +144,17 @@ export const StatusMessage = ({ statusColor = 'default'; statusMessage = ( - The index pattern you've entered doesn't match any indices. - You can match any of your {allIndices.length} indices, below. + + ) }} + /> ); } diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js index 6acd867e8fd6d..cd016e5f16e95 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.js @@ -38,6 +38,10 @@ import { EuiCallOut, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { I18nContext, FormattedMessage } = ReactI18n; + export class StepIndexPattern extends Component { static propTypes = { allIndices: PropTypes.array.isRequired, @@ -205,16 +209,24 @@ export class StepIndexPattern extends Component { return ( } iconType="help" color="warning" > -

There's already an index pattern called `{query}`

+

+

); } - renderHeader({ exactMatchedIndices: indices }) { + renderHeader({ exactMatchedIndices: indices }, intl) { const { goToNextStep } = this.props; const { query, showingIndexPatternQueryErrors, indexPatternExists } = this.state; @@ -227,7 +239,10 @@ export class StepIndexPattern extends Component { containsErrors = true; } else if (!containsInvalidCharacters(query, ILLEGAL_CHARACTERS)) { - errors.push(`An index pattern cannot contain spaces or the characters: ${characterList}`); + errors.push(intl.formatMessage({ + id: 'kbn.management.indexPattern.create.step.invalidCharacters.errorMessage', + defaultMessage: 'An index pattern cannot contain spaces or the characters: {characterList}' + }, { characterList })); containsErrors = true; } @@ -262,7 +277,9 @@ export class StepIndexPattern extends Component { return ( - {this.renderHeader(matchedIndices)} + + {intl => this.renderHeader(matchedIndices, intl)} + {this.renderLoadingState(matchedIndices)} {this.renderIndexPatternExists()} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap index c6b7f0cd1a268..1af6804d6f0b5 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/__tests__/__snapshots__/step_time_field.test.js.snap @@ -44,7 +44,11 @@ exports[`StepTimeField should render a loading state when creating the index pat - Creating index pattern... +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/action_buttons/action_buttons.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/action_buttons/action_buttons.js index b8d11fbf238c8..3a92f7bf66641 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/action_buttons/action_buttons.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/action_buttons/action_buttons.js @@ -26,6 +26,10 @@ import { EuiButtonEmpty } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const ActionButtons = ({ goToPreviousStep, submittable, @@ -37,7 +41,10 @@ export const ActionButtons = ({ iconType="arrowLeft" onClick={goToPreviousStep} > - Back + @@ -47,7 +54,10 @@ export const ActionButtons = ({ fill onClick={createIndexPattern} > - Create index pattern + diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap index 155d41f3b8d72..094ed3d56a8fa 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/advanced_options/__tests__/__snapshots__/advanced_options.test.js.snap @@ -10,7 +10,11 @@ exports[`AdvancedOptions should hide if not showing 1`] = ` type="button" > - Show advanced options + - Show advanced options + { isVisible - ? (Hide advanced options) - : (Show advanced options) + ? ( + + + + ) + : ( + + + + ) } { isVisible ? - - - Kibana will provide a unique identifier for each index pattern. - If you do not want to use this unique ID, enter a custom one. - - } - > - - - + + {intl => ( + + + + + } + > + + + + )} + : null } diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap index 4744d49588e14..079a937ef8953 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/__tests__/__snapshots__/header.test.js.snap @@ -6,7 +6,11 @@ exports[`Header should render normally 1`] = ` size="s" >

- Step 2 of 2: Configure settings +

- You've defined - - ki* - - as your index pattern. Now you can specify some settings before we create it. + + ki* + , + } + } + /> diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js index 00660a87c3289..840629ee28961 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/header/header.js @@ -25,20 +25,30 @@ import { EuiText, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export const Header = ({ indexPattern, }) => (

- Step 2 of 2: Configure settings +

- You've defined {indexPattern} as your index pattern. - Now you can specify some settings before we create it. + {indexPattern} }} + />
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap index b04aa723bc5e7..43833c69dc974 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/__tests__/__snapshots__/time_field.test.js.snap @@ -9,10 +9,15 @@ exports[`TimeField should render a loading state 1`] = ` helpText={

- The Time Filter will use this field to filter your data by time. -

-

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. + , + } + } + />

} @@ -31,7 +36,11 @@ exports[`TimeField should render a loading state 1`] = ` grow={false} > - Time Filter field name + } > - + `; @@ -75,10 +68,15 @@ exports[`TimeField should render a selected time field 1`] = ` helpText={

- The Time Filter will use this field to filter your data by time. -

-

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. + , + } + } + />

} @@ -97,7 +95,11 @@ exports[`TimeField should render a selected time field 1`] = ` grow={false} > - Time Filter field name +
- Refresh + @@ -148,10 +154,15 @@ exports[`TimeField should render normally 1`] = ` helpText={

- The Time Filter will use this field to filter your data by time. -

-

- You can choose not to have a time field, but you will not be able to narrow down your data by a time range. + , + } + } + />

} @@ -170,7 +181,11 @@ exports[`TimeField should render normally 1`] = ` grow={false} > - Time Filter field name + - Refresh + @@ -218,7 +237,11 @@ exports[`TimeField should render something if hiding time field 1`] = ` grow={true} >

- The indices which match this index pattern don't contain any time fields. +

diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js index b720ca37d2b43..e00b3f10f4ec2 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/components/time_field/time_field.js @@ -32,6 +32,10 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { I18nContext, FormattedMessage } = ReactI18n; + export const TimeField = ({ isVisible, fetchTimeFields, @@ -46,7 +50,12 @@ export const TimeField = ({ label={ - Time Filter field name + + + { isLoading ? ( @@ -57,7 +66,10 @@ export const TimeField = ({ className="timeFieldRefreshButton" onClick={fetchTimeFields} > - Refresh + ) } @@ -66,20 +78,35 @@ export const TimeField = ({ } helpText={
-

The Time Filter will use this field to filter your data by time.

-

You can choose not to have a time field, but you will not be able to narrow down your data by a time range.

+

+ }} + /> +

} > { isLoading ? ( - + + {intl => ( + + )} + ) : ( : -

The indices which match this index pattern don't contain any time fields.

+

+ +

} diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js index 7b82b62d06c70..0dbb4ea2515c1 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/components/step_time_field/step_time_field.js @@ -35,6 +35,10 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; +import { ReactI18n } from '@kbn/i18n'; + +const { FormattedMessage } = ReactI18n; + export class StepTimeField extends Component { static propTypes = { indexPattern: PropTypes.string.isRequired, @@ -121,7 +125,12 @@ export class StepTimeField extends Component {
- Creating index pattern... + + +
diff --git a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js index 192afb5174242..2af59c36315bb 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js +++ b/src/core_plugins/kibana/public/management/sections/indices/create_index_pattern_wizard/render.js @@ -21,7 +21,10 @@ import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; import { CreateIndexPatternWizard } from './create_index_pattern_wizard'; +import { ReactI18n } from '@kbn/i18n'; + const CREATE_INDEX_PATTERN_DOM_ELEMENT_ID = 'createIndexPatternReact'; +const { I18nProvider } = ReactI18n; export function renderCreateIndexPatternWizard( initialQuery, @@ -33,10 +36,12 @@ export function renderCreateIndexPatternWizard( } render( - , + + + , node, ); } diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html index 6ef99c10c25b3..4202d524d2141 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_index_pattern.html @@ -5,7 +5,7 @@ data-test-subj="editIndexPattern" class="kuiViewContent" role="region" - aria-label="Index pattern details" + aria-label="{{'kbn.management.indexPattern.edit.details.aria' | i18n: {defaultMessage: 'Index pattern details'} }}" > - Time Filter field name: {{indexPattern.timeFieldName}} +

- This page lists every field in the {{::indexPattern.title}} index and the field's associated core type as recorded by Elasticsearch. To change a field type, use the Elasticsearch + - Mapping API +

@@ -37,16 +42,16 @@ >
- - Support for repeating index patterns removed +
- Support for time-interval based index patterns has been removed! In the next major - version of Kibana this index patterns will stop working. Migrate saved objects that - use this index pattern to a wildcard pattern and delete this one. +
@@ -57,14 +62,16 @@ >
- - Mapping conflict - +
- {{conflictFields.length > 1 ? conflictFields.length : 'A'}} field{{conflictFields.length > 1 ? 's' : ''}} {{conflictFields.length > 1 ? 'are' : 'is'}} defined as several types (string, integer, etc) across the indices that match this pattern. You may still be able to use these conflict fields in parts of Kibana, but they will be unavailable for functions that require Kibana to know their type. Correcting this issue will require reindexing your data. +
@@ -96,9 +103,9 @@ @@ -115,7 +122,9 @@ ng-change="changeFilter('indexedFieldTypeFilter', indexedFieldTypeFilter)" ng-options="o for o in indexedFieldTypes" > - + @@ -130,7 +139,9 @@ ng-change="changeFilter('scriptedFieldLanguageFilter', scriptedFieldLanguageFilter)" ng-options="o for o in scriptedFieldLanguages" > - + diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js index cdc65a110636f..469b205fd7651 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/edit_sections.js @@ -19,7 +19,7 @@ import _ from 'lodash'; -export function IndicesEditSectionsProvider() { +export function IndicesEditSectionsProvider(i18n) { return function (indexPattern) { const fieldCount = _.countBy(indexPattern.fields, function (field) { @@ -34,17 +34,17 @@ export function IndicesEditSectionsProvider() { return [ { - title: 'Fields', + title: i18n('kbn.management.indexPattern.edit.tabs.fields.header', { defaultMessage: 'Fields' }), index: 'indexedFields', count: fieldCount.indexed }, { - title: 'Scripted fields', + title: i18n('kbn.management.indexPattern.edit.tabs.scripted.header', { defaultMessage: 'Scripted fields' }), index: 'scriptedFields', count: fieldCount.scripted }, { - title: 'Source filters', + title: i18n('kbn.management.indexPattern.edit.tabs.source.header', { defaultMessage: 'Source filters' }), index: 'sourceFilters', count: fieldCount.sourceFilters } diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html index 794f1da2a7b79..a9699e721b627 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/field_controls.html @@ -2,7 +2,7 @@ @@ -12,7 +12,7 @@ ng-if="field.scripted" ng-click="remove(field)" class="kuiButton kuiButton--danger kuiButton--small" - aria-label="Delete" + aria-label="{{'kbn.management.indexPattern.edit.deleteField.button' | i18n: {defaultMessage: 'Delete'} }}" > diff --git a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html index 2e2d828cd6e2e..054788340d358 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html +++ b/src/core_plugins/kibana/public/management/sections/indices/edit_index_pattern/index_header/index_header.html @@ -18,8 +18,8 @@