Skip to content

Commit

Permalink
Update after review
Browse files Browse the repository at this point in the history
Updates following review comments:
#8766 (review)
  • Loading branch information
hickeyma committed Mar 6, 2017
1 parent 4dbf3a0 commit c2438de
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 37 deletions.
11 changes: 11 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ module.exports = function (grunt) {
}
}()),

i18nextract: {
default_options: {
src: [ 'src/**/*.js', 'src/**/*.html' ],
lang: ['en'],
dest: 'build/tmp'
}
},

nodeVersion: grunt.file.read('.node-version').trim(),

meta: {
Expand Down Expand Up @@ -65,4 +73,7 @@ module.exports = function (grunt) {
// load task definitions
grunt.task.loadTasks('tasks');
grunt.task.loadTasks('tasks/build');

// load NPM tasks
grunt.loadNpmTasks('grunt-angular-translate');
};
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ After
`_create.html`
--------------------------------------------------------
<h1 translate>KIBANA-H1_CONFIGURE_INDEX_PATTERN</h1>
<p translate>KIBANA-MUST_CONFIGURE_INDEX_PATTERN</p>
<h1 translate="KIBANA-CONFIGURE_INDEX_PATTERN"</h1>
<p translate="KIBANA-MUST_CONFIGURE_INDEX_PATTERN"</p>
--------------------------------------------------------
`en.json`
--------------------------------------------------------------------------------
{
"KIBANA-H1_CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-MUST_CONFIGURE_INDEX_PATTERN": "In order to use Kibana you must…"
}
--------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
"expect.js": "0.3.1",
"faker": "1.1.0",
"grunt": "1.0.1",
"grunt-angular-translate": "0.3.0",
"grunt-aws-s3": "0.14.5",
"grunt-babel": "6.0.0",
"grunt-cli": "0.1.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<kbn-management-indices>
<div ng-controller="managementIndicesCreate" class="kbn-management-indices-create">
<div class="page-header">
<h1 translate="KIBANA-H1_CONFIGURE_INDEX_PATTERN"></h1>
<p translate="KIBANA-MUST_CONFIGURE_INDEX_PATTERN"></p>
<h1 translate="KIBANA-CONFIGURE_INDEX_PATTERN"></h1>
<p translate="KIBANA-MUST_CONFIGURE_INDEX_PATTERN"></p>
</div>
<div>
<form name="form" role="form" class="well" ng-submit="createIndexPattern()">
Expand Down Expand Up @@ -34,15 +34,15 @@ <h1 translate="KIBANA-H1_CONFIGURE_INDEX_PATTERN"></h1>
<input
ng-model="index.isTimeBased"
type="checkbox">
<span translate="KIBANA-CONTAINS_TIME_BASED_EVENTS_CHECKBOX"></span>
<span translate="KIBANA-CONTAINS_TIME_BASED_EVENTS"></span>
</label>
</div>

<div class="form-group" ng-if="index.isTimeBased">
<label>
<span translate="KIBANA-TIME_FIELD_NAME"></span>
&nbsp;
<kbn-info info="This field will be used to filter events with the global time filter"></kbn-info>
<kbn-info info="{{ 'KIBANA-FIELD_FILTER_EVENTS_GLOBAL_TIME' | translate }}"></kbn-info>
&nbsp;
<small>
<a ng-click="refreshFieldList();" translate="KIBANA-REFRESH_FIELDS"></a>
Expand All @@ -61,37 +61,50 @@ <h1 translate="KIBANA-H1_CONFIGURE_INDEX_PATTERN"></h1>
<div class="form-group" ng-if="canExpandIndices()">
<label>
<input ng-model="index.notExpandable" type="checkbox">
<span translate="KIBANA-EXPAND_INDEX_PATTERN_WARNING"></span>
<span translate="KIBANA-NOT_EXPAND_INDEX_PATTERN"></span>
<small translate="KIBANA-NOT_RECOMMENDED"></small>
</label>

<div ng-if="index.notExpandable" class="alert alert-info">
<span translate="KIBANA-NOT_EXPANDABLE_PART1"></span>
<span translate="KIBANA-NOT_EXPANDABLE"></span>

<span translate="KIBANA-NOT_EXPANDABLE_PART2" translate-values="{ indexName: '{{index.name}}' }"></span>
<span translate="KIBANA-ES_QUERY"></span>
<em translate="KIBANA-INDEX_NAME_VAR" translate-values="{ indexName: '{{index.name}}' }"></em>
<span translate="KIBANA-SEARCH_ALL_DATA"></span>
</div>

<p class="help-block" translate="KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE_HELP"></p>
<p class="help-block" translate="KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE"></p>

<p class="help-block" translate="KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE_EXAMPLE_HELP"></p>
<p class="help-block">
<span translate="KIBANA-SEARCH_AGAINST_INDX_PATTERN"></span>
<em translate="KIBANA-LOGSTASH_WILDCARD"></em>
<span translate="KIBANA-ACTUALLY_QUERY"></span>
<em translate="KIBANA-EXAMPLE_TIME_RANGE"></em>
<span translate="KIBANA-FALL_WITHIN_CURRENT_TIME_RANGE"></span>
</p>
</div>

<div class="form-group time-and-pattern">
<label ng-if="index.isTimeBased">
<input ng-model="index.nameIsPattern" type="checkbox">
<span translate="KIBANA-INDEX_NAME_IS_PATTERN_CHECKBOX"></span>
<span translate="KIBANA-INDEX_NAME_CREATED_BY_EVENT_TIMES"></span>
<small translate="KIBANA-DEPRECATED"></small>
</label>
</div>

<div class="form-group" ng-if="index.isTimeBased && index.nameIsPattern">
<div class="alert alert-warning">
</p>
<h4 translate="KIBANA-ALERT_INDEX_PATTERN_DEPRECATED"></h4>
<p translate="KIBANA-RECOMMEND_WILD_CARD_PATTERN"></p>
<p translate="KIBANA-RECOMMEND_WILD_CARD_PATTERN_DETAILS"></p>
<p>
<span translate="KIBANA-WE"></span>
<strong translate="KIBANA-STRONGLY_RECOMMEND"></strong>
<span translate="KIBANA-WILD_CARD_PATTERN"></span>
</p>
</div>
<label>
<span translate="KIBANA-INDEX_PATTERN_INTERVAL"></span>&nbsp;
<kbn-info info="The interval at which index names rotate."></kbn-info>
<kbn-info info="{{ 'KIBANA-INTERVAL_INDEX_NAMES_ROTATE' | translate }}"></kbn-info>
</label>
<select
required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ uiRoutes
});

uiModules.get('apps/management')
.controller('managementIndicesCreate', function ($scope, kbnUrl, Private, Notifier, indexPatterns, es, config, Promise) {
.controller('managementIndicesCreate', function ($scope, kbnUrl, Private, Notifier, indexPatterns, es, config, Promise, $translate) {
const notify = new Notifier();
const refreshKibanaIndex = Private(RefreshKibanaIndex);
const intervals = indexPatterns.intervals;
Expand Down Expand Up @@ -88,7 +88,7 @@ uiModules.get('apps/management')
})
.catch(function (err) {
if (err instanceof IndexPatternMissingIndices) {
notify.error('Could not locate any indices matching that pattern. Please add the index to Elasticsearch');
notify.error($translate.instant('KIBANA-NO_INDICES_MATCHING_PATTERN'));
}
else notify.fatal(err);
});
Expand Down Expand Up @@ -192,12 +192,12 @@ uiModules.get('apps/management')
return;
}

patternErrors.push('Pattern does not match any existing indices');
patternErrors.push($translate.instant('KIBANA-PATTERN_DOES_NOT_MATCH_EXIST_INDICES'));
const radius = Math.round(index.sampleCount / 2);
const samples = intervals.toIndexList(index.name, index.nameInterval, -radius, radius);

if (_.uniq(samples).length !== samples.length) {
patternErrors.push('Invalid pattern, interval does not create unique index names');
patternErrors.push($translate.instant('KIBANA-INVALID_NON_UNIQUE_INDEX_NAME_CREATED'));
} else {
index.samples = samples;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ <h5>
ng-if="!defaultIndex"
class="sidebar-item">
<div class="sidebar-item-title full-title">
<span class="label label-warning">Warning</span> No default index pattern. You must select or create one to continue.
<span class="label label-warning" translate="KIBANA-WARNING"></span>
<p translate="KIBANA-NO_DEFAULT_INDEX_PATTERN"></p>
</div>
</li>
<li
Expand Down
37 changes: 27 additions & 10 deletions src/core_plugins/kibana/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
{
"UI-WELCOME_MESSAGE": "Loading Kibana",
"UI-WELCOME_ERROR": "Kibana did not load properly. Check the server output for more information.",
"KIBANA-H1_CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-CONFIGURE_INDEX_PATTERN": "Configure an index pattern",
"KIBANA-MUST_CONFIGURE_INDEX_PATTERN": "In order to use Kibana you must configure at least one index pattern. Index patterns are used to identify the Elasticsearch index to run search and analytics against. They are also used to configure fields.",
"KIBANA-CONTAINS_TIME_BASED_EVENTS_CHECKBOX": "Index contains time-based events",
"KIBANA-INDEX_NAME_IS_PATTERN_CHECKBOX": "Use event times to create index names <small>[DEPRECATED]</small>",
"KIBANA-CONTAINS_TIME_BASED_EVENTS": "Index contains time-based events",
"KIBANA-INDEX_NAME_CREATED_BY_EVENT_TIMES": "Use event times to create index names ",
"KIBANA-DEPRECATED": "[DEPRECATED]",
"KIBANA-ALERT_INDEX_PATTERN_DEPRECATED": "Time-interval based index patterns are deprecated!",
"KIBANA-RECOMMEND_WILD_CARD_PATTERN": " We <strong>strongly recommend</strong> using wildcard pattern names instead of time-interval based index patterns.",
"KIBANA-WE": " We",
"KIBANA-STRONGLY_RECOMMEND": " strongly recommend",
"KIBANA-WILD_CARD_PATTERN": " using wildcard pattern names instead of time-interval based index patterns.",
"KIBANA-RECOMMEND_WILD_CARD_PATTERN_DETAILS": "Kibana is now smart enough to automatically determine which indices to search against within the current time range for wildcard index patterns. This means that wildcard index patterns now get the same performance optimizations when searching within a time range as time-interval patterns.",
"KIBANA-INDEX_PATTERN_INTERVAL": "Index pattern interval",
"KIBANA-INDEX_NAME_OR_PATTERN": "Index name or pattern",
"KIBANA-WILDCARD_DYNAMIC_INDEX_PATTERNS": "Patterns allow you to define dynamic index names using * as a wildcard. Example: logstash-*",
"KIBANA-STATIC_TEXT_IN_DYNAMIC_INDEX_PATTERNS": "Patterns allow you to define dynamic index names. Static text in an index name is denoted using brackets. Example: [logstash-]YYYY.MM.DD. Please note that weeks are setup to use ISO weeks which start on Monday.",
"KIBANA-NOTE_COLON": "Note:",
"KIBANA-WEEKLY_ISO_NOTICE": "I noticed you are using weekly indices. Kibana requires ISO weeks be used in your index creation.",
"KIBANA-EXPAND_INDEX_PATTERN_WARNING": "Do not expand index pattern when searching <small>(Not recommended)</small>",
"KIBANA-NOT_EXPANDABLE_PART1": "This index pattern will be queried directly rather than being expanded into more performant searches against individual indices.",
"KIBANA-NOT_EXPANDABLE_PART2": "Elasticsearch will receive a query against <em>{{indexName}}</em> and will have to search through all matching indices regardless of whether they have data that matches the current time range.",
"KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE_HELP": "By default, searches against any time-based index pattern that contains a wildcard will automatically be expanded to query only the indices that contain data within the currently selected time range.",
"KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE_EXAMPLE_HELP": "Searching against the index pattern <em>logstash-*</em> will actually query elasticsearch for the specific matching indices (e.g. <em>logstash-2015.12.21</em>) that fall within the current time range.",
"KIBANA-NOT_EXPAND_INDEX_PATTERN": "Do not expand index pattern when searching ",
"KIBANA-NOT_RECOMMENDED": "(Not recommended)",
"KIBANA-NOT_EXPANDABLE": "This index pattern will be queried directly rather than being expanded into more performant searches against individual indices.",
"KIBANA-ES_QUERY": "Elasticsearch will receive a query against ",
"KIBANA-INDEX_NAME_VAR": "{{indexName}} ",
"KIBANA-SEARCH_ALL_DATA": "and will have to search through all matching indices regardless of whether they have data that matches the current time range.",
"KIBANA-WILDCARD_DEFAULT_EXPANDED_TO_CURRENT_TIME_RANGE": "By default, searches against any time-based index pattern that contains a wildcard will automatically be expanded to query only the indices that contain data within the currently selected time range.",
"KIBANA-SEARCH_AGAINST_INDX_PATTERN": "Searching against the index pattern ",
"KIBANA-LOGSTASH_WILDCARD": "logstash-*",
"KIBANA-ACTUALLY_QUERY": " will actually query elasticsearch for the specific matching indices (e.g. ",
"KIBANA-EXAMPLE_TIME_RANGE": "logstash-2015.12.21",
"KIBANA-FALL_WITHIN_CURRENT_TIME_RANGE": ") that fall within the current time range.",
"KIBANA-SAMPLE_ALERT": "Attempted to match the following indices and aliases:",
"KIBANA-EXPAND_SEARCH": "Expand Search",
"KIBANA-EXISTING_MATCH_PERCENT": "Pattern matches {{indexExistingMatchPercent}} of existing indices and aliases",
Expand All @@ -28,5 +38,12 @@
"KIBANA-REFRESH_FIELDS": "refresh fields",
"KIBANA-INVALID_INDEX_PATTERN": "Invalid index name pattern.",
"KIBANA-DATE_FORMAT_DOCS": "Date Format Documentation",
"KIBANA-WIKI_ISO_WEEK_DATE": "Wikipedia: ISO Week Date"
"KIBANA-WIKI_ISO_WEEK_DATE": "Wikipedia: ISO Week Date",
"KIBANA-NO_INDICES_MATCHING_PATTERN": "Could not locate any indices matching that pattern. Please add the index to Elasticsearch",
"KIBANA-PATTERN_DOES_NOT_MATCH_EXIST_INDICES": "Pattern does not match any existing indices",
"KIBANA-INVALID_NON_UNIQUE_INDEX_NAME_CREATED": "Invalid pattern, interval does not create unique index names",
"KIBANA-FIELD_FILTER_EVENTS_GLOBAL_TIME" : "This field will be used to filter events with the global time filter",
"KIBANA-INTERVAL_INDEX_NAMES_ROTATE" : "The interval at which index names rotate.",
"KIBANA-WARNING" : "Warning",
"KIBANA-NO_DEFAULT_INDEX_PATTERN" : "No default index pattern. You must select or create one to continue."
}
4 changes: 2 additions & 2 deletions src/ui/ui_i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export class UiI18n {
* do with the uiExports defined by each plugin.
*
* This consumer will allow plugins to define export with the
* "language" type like so:
* "translations" type like so:
*
* new kibana.Plugin({
* uiExports: {
* languages: [
* translations: [
* resolve(__dirname, './translations/es.json'),
* ],
* },
Expand Down
5 changes: 5 additions & 0 deletions tasks/build/extract_angular_translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function (grunt) {
grunt.registerTask('_build:extractAngularTranslations', function () {
grunt.task.run('i18nextract');
});
};
1 change: 1 addition & 0 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (grunt) {
'_build:babelOptions',
'_build:plugins',
'_build:data',
'_build:extractAngularTranslations',
'_build:verifyTranslations',
'_build:packageJson',
'_build:readme',
Expand Down
8 changes: 5 additions & 3 deletions tasks/build/verify_translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import * as i18nVerify from '../utils/i18n_verify_keys';

export default function (grunt) {
grunt.registerTask('_build:verifyTranslations', function () {

grunt.task.requires('_build:extractAngularTranslations');

const done = this.async();

const serverConfig = {
Expand Down Expand Up @@ -46,13 +49,12 @@ export default function (grunt) {

function verifyTranslations(uiI18nObj)
{
const angularTranslations = require(fromRoot('build/tmp/en.json'));
const translationKeys = Object.keys(angularTranslations);
const translationPatterns = [
{ regEx: 'translate=\"([^\"]+)\"',
parsePaths: [fromRoot('/src/core_plugins/kibana/*.html')] },
{ regEx: 'i18n\\(\'(.*)\'\\)',
parsePaths: [fromRoot('/src/ui/views/*.jade')] }
];
const translationKeys = [];

const keyPromises = _.map(translationPatterns, (pattern) => {
return i18nVerify.getTranslationKeys(pattern.regEx, pattern.parsePaths)
Expand Down
2 changes: 1 addition & 1 deletion webpackShims/ui-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define(function (require) {
$translateProvider.preferredLanguage('default');
// Enable escaping of HTML
// issue in https://angular-translate.github.io/docs/#/guide/19_security
$translateProvider.useSanitizeValueStrategy('escapeParameters');
$translateProvider.useSanitizeValueStrategy('escape');
});

});

0 comments on commit c2438de

Please sign in to comment.