From 14579e7f4b5bfcec5e76cadff8c099656626ec62 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 10 Oct 2018 16:49:52 +0300 Subject: [PATCH 1/5] translate Coordinate Map --- .i18nrc.json | 1 + .../public/base_maps_visualization.js | 5 +- .../public/coordinate_maps_visualization.js | 5 +- .../public/editors/_tooltip_formatter.js | 6 +- .../public/editors/tile_map_vis_params.html | 33 ++++-- .../tile_map/public/editors/wms_options.html | 109 +++++++++++------- .../tile_map/public/geohash_layer.js | 8 +- .../tile_map/public/tile_map_vis.js | 33 ++++-- 8 files changed, 131 insertions(+), 69 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 8ac1cf0fbd1ea..1c5f90e59c26c 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -6,6 +6,7 @@ "markdownVis": "src/core_plugins/markdown_vis", "metricVis": "src/core_plugins/metric_vis", "statusPage": "src/core_plugins/status_page", + "tileMap": "src/core_plugins/tile_map", "xpack.idxMgmt": "x-pack/plugins/index_management" }, "exclude": [ diff --git a/src/core_plugins/tile_map/public/base_maps_visualization.js b/src/core_plugins/tile_map/public/base_maps_visualization.js index c812061d9d9e1..f70ef057cb75a 100644 --- a/src/core_plugins/tile_map/public/base_maps_visualization.js +++ b/src/core_plugins/tile_map/public/base_maps_visualization.js @@ -18,6 +18,7 @@ */ import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; import { KibanaMap } from 'ui/vis/map/kibana_map'; import * as Rx from 'rxjs'; import { filter, first } from 'rxjs/operators'; @@ -195,7 +196,9 @@ export function BaseMapsVisualizationProvider(serviceSettings) { } async _updateData() { - throw new Error('Child should implement this method to respond to data-update'); + throw new Error(i18n.translate('tileMap.baseMapsVisualization.childShouldImplementMethodErrorMessage', { + defaultMessage: 'Child should implement this method to respond to data-update', + })); } _hasESResponseChanged(data) { diff --git a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js index 7018db87c89d2..b202e096b17b8 100644 --- a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js +++ b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js @@ -18,6 +18,7 @@ */ import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; import { GeohashLayer } from './geohash_layer'; import { BaseMapsVisualizationProvider } from './base_maps_visualization'; import { AggConfig } from 'ui/vis/agg_config'; @@ -220,7 +221,9 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) { esResp = await searchSource.fetch(); } catch(error) { toastNotifications.addDanger({ - title: `Unable to get bounds`, + title: i18n.translate('tileMap.coordinateMapsVisualization.unableToGetBoundErrorTitle', { + defaultMessage: 'Unable to get bounds', + }), text: `${error.message}`, }); return; diff --git a/src/core_plugins/tile_map/public/editors/_tooltip_formatter.js b/src/core_plugins/tile_map/public/editors/_tooltip_formatter.js index 4cc73a518f44d..105bc510d8b2e 100644 --- a/src/core_plugins/tile_map/public/editors/_tooltip_formatter.js +++ b/src/core_plugins/tile_map/public/editors/_tooltip_formatter.js @@ -19,7 +19,7 @@ import $ from 'jquery'; -export function TileMapTooltipFormatterProvider($compile, $rootScope) { +export function TileMapTooltipFormatterProvider($compile, $rootScope, i18n) { const $tooltipScope = $rootScope.$new(); const $el = $('
').html(require('./_tooltip.html')); @@ -37,11 +37,11 @@ export function TileMapTooltipFormatterProvider($compile, $rootScope) { value: metricAgg.fieldFormatter()(feature.properties.value) }, { - label: 'Latitude', + label: i18n('tileMap.tooltipFormatter.latitudeLabel', { defaultMessage: 'Latitude' }), value: feature.geometry.coordinates[1] }, { - label: 'Longitude', + label: i18n('tileMap.tooltipFormatter.longitudeLabel', { defaultMessage: 'Longitude' }), value: feature.geometry.coordinates[0] } ]; diff --git a/src/core_plugins/tile_map/public/editors/tile_map_vis_params.html b/src/core_plugins/tile_map/public/editors/tile_map_vis_params.html index 9afc714e43e5c..b776849600ad2 100644 --- a/src/core_plugins/tile_map/public/editors/tile_map_vis_params.html +++ b/src/core_plugins/tile_map/public/editors/tile_map_vis_params.html @@ -1,7 +1,11 @@
- +
- +
- +
 
diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html index 49f01466a73e2..ecfd2703388c1 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.html +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -3,16 +3,21 @@
-
- Base Layer Settings -
+
- +
 
@@ -45,14 +53,20 @@
-

WMS is an OGC standard for map image services. For more information, go here.

+

-
-

* if this parameter is incorrect, maps will fail to load.

+

diff --git a/src/core_plugins/tile_map/public/geohash_layer.js b/src/core_plugins/tile_map/public/geohash_layer.js index 7fa4c1ab51331..570255e51c441 100644 --- a/src/core_plugins/tile_map/public/geohash_layer.js +++ b/src/core_plugins/tile_map/public/geohash_layer.js @@ -19,6 +19,7 @@ import L from 'leaflet'; import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; import { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer'; import { HeatmapMarkers } from './markers/heatmap'; @@ -83,7 +84,12 @@ export class GeohashLayer extends KibanaMapLayer { }, this._zoom, this._featureCollectionMetaData.max); break; default: - throw new Error(`${this._geohashOptions.mapType} mapType not recognized`); + throw new Error(i18n.translate('tileMap.geohashLayer.mapTitle', { + defaultMessage: '{mapType} mapType not recognized', + values: { + mapType: this._geohashOptions.mapType, + }, + })); } diff --git a/src/core_plugins/tile_map/public/tile_map_vis.js b/src/core_plugins/tile_map/public/tile_map_vis.js index 736939e1dd787..915cfbbfc9fad 100644 --- a/src/core_plugins/tile_map/public/tile_map_vis.js +++ b/src/core_plugins/tile_map/public/tile_map_vis.js @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options'; import './editors/tile_map_vis_params'; import { supports } from 'ui/utils/supports'; @@ -36,9 +37,13 @@ VisTypesRegistryProvider.register(function TileMapVisType(Private, getAppState, return VisFactory.createBaseVisualization({ name: 'tile_map', - title: 'Coordinate Map', + title: i18n.translate('tileMap.vis.mapTitle', { + defaultMessage: 'Coordinate Map', + }), icon: 'visMapCoordinate', - description: 'Plot latitude and longitude coordinates on a map', + description: i18n.translate('tileMap.vis.mapTitle', { + defaultMessage: 'Plot latitude and longitude coordinates on a map', + }), category: CATEGORY.MAP, visConfig: { canDesaturate: !!supports.cssFilters, @@ -63,16 +68,24 @@ VisTypesRegistryProvider.register(function TileMapVisType(Private, getAppState, colorSchemas: Object.keys(truncatedColorMaps), legendPositions: [{ value: 'bottomleft', - text: 'bottom left', + text: i18n.translate('tileMap.vis.map.editorConfig.legendPositions.bottomLeftText', { + defaultMessage: 'bottom left', + }), }, { value: 'bottomright', - text: 'bottom right', + text: i18n.translate('tileMap.vis.map.editorConfig.legendPositions.bottomRightText', { + defaultMessage: 'bottom right', + }), }, { value: 'topleft', - text: 'top left', + text: i18n.translate('tileMap.vis.map.editorConfig.legendPositions.topLeftText', { + defaultMessage: 'top left', + }), }, { value: 'topright', - text: 'top right', + text: i18n.translate('tileMap.vis.map.editorConfig.legendPositions.topRightText', { + defaultMessage: 'top right', + }), }], mapTypes: [ 'Scaled Circle Markers', @@ -87,7 +100,9 @@ VisTypesRegistryProvider.register(function TileMapVisType(Private, getAppState, { group: 'metrics', name: 'metric', - title: 'Value', + title: i18n.translate('tileMap.vis.map.editorConfig.schemas.metricTitle', { + defaultMessage: 'Value', + }), min: 1, max: 1, aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality', 'top_hits'], @@ -98,7 +113,9 @@ VisTypesRegistryProvider.register(function TileMapVisType(Private, getAppState, { group: 'buckets', name: 'segment', - title: 'Geo Coordinates', + title: i18n.translate('tileMap.vis.map.editorConfig.schemas.geoCoordinatesTitle', { + defaultMessage: 'Geo Coordinates', + }), aggFilter: 'geohash_grid', min: 1, max: 1 From 58d6f002d236dc33d4d8dee728380e795ed3afb7 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 10 Oct 2018 20:03:34 +0300 Subject: [PATCH 2/5] fix duplicate translation id --- src/core_plugins/tile_map/public/editors/wms_options.html | 2 +- src/core_plugins/tile_map/public/tile_map_vis.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html index ecfd2703388c1..d2f2abb92d410 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.html +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -66,7 +66,7 @@ i18n-id="tileMap.wmsOptions.wmsUrlLabel" i18n-default-message="WMS url*" > - + Date: Thu, 11 Oct 2018 11:56:48 +0300 Subject: [PATCH 3/5] inject i18n service instead of importing from core package --- src/core_plugins/tile_map/public/base_maps_visualization.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/tile_map/public/base_maps_visualization.js b/src/core_plugins/tile_map/public/base_maps_visualization.js index f70ef057cb75a..d17ee05247dbe 100644 --- a/src/core_plugins/tile_map/public/base_maps_visualization.js +++ b/src/core_plugins/tile_map/public/base_maps_visualization.js @@ -18,7 +18,6 @@ */ import _ from 'lodash'; -import { i18n } from '@kbn/i18n'; import { KibanaMap } from 'ui/vis/map/kibana_map'; import * as Rx from 'rxjs'; import { filter, first } from 'rxjs/operators'; @@ -28,7 +27,7 @@ import { toastNotifications } from 'ui/notify'; const MINZOOM = 0; const MAXZOOM = 22;//increase this to 22. Better for WMS -export function BaseMapsVisualizationProvider(serviceSettings) { +export function BaseMapsVisualizationProvider(serviceSettings, i18n) { /** * Abstract base class for a visualization consisting of a map with a single baselayer. @@ -196,7 +195,7 @@ export function BaseMapsVisualizationProvider(serviceSettings) { } async _updateData() { - throw new Error(i18n.translate('tileMap.baseMapsVisualization.childShouldImplementMethodErrorMessage', { + throw new Error(i18n('tileMap.baseMapsVisualization.childShouldImplementMethodErrorMessage', { defaultMessage: 'Child should implement this method to respond to data-update', })); } From 53b0071c8e5eedc68e94ba4ec8f9297126c529b2 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 16 Oct 2018 15:08:17 +0300 Subject: [PATCH 4/5] fix code review comments --- .../tile_map/public/editors/wms_options.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/core_plugins/tile_map/public/editors/wms_options.html b/src/core_plugins/tile_map/public/editors/wms_options.html index d2f2abb92d410..ac211717acd6e 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.html +++ b/src/core_plugins/tile_map/public/editors/wms_options.html @@ -114,11 +114,7 @@
-