From 73dc0c6c6109e1e9db6fc1fec5384e4b82f9f5d8 Mon Sep 17 00:00:00 2001 From: pavel06081991 Date: Mon, 29 Oct 2018 14:57:18 +0300 Subject: [PATCH] Translations for Coordinate Map (#23952) (#24711) translate Coordinate Map --- .i18nrc.json | 1 + .../public/base_maps_visualization.js | 6 +- .../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 | 104 ++++++++++-------- .../tile_map/public/editors/wms_options.js | 3 +- .../tile_map/public/geohash_layer.js | 8 +- .../tile_map/public/tile_map_vis.js | 33 ++++-- 9 files changed, 128 insertions(+), 71 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 59cfc9591ce88..0e56bc59ed398 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -8,6 +8,7 @@ "metricVis": "src/core_plugins/metric_vis", "regionMap": "src/core_plugins/region_map", "statusPage": "src/core_plugins/status_page", + "tileMap": "src/core_plugins/tile_map", "tagCloud": "src/core_plugins/tagcloud", "xpack.idxMgmt": "x-pack/plugins/index_management", "xpack.watcher": "x-pack/plugins/watcher" 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..d17ee05247dbe 100644 --- a/src/core_plugins/tile_map/public/base_maps_visualization.js +++ b/src/core_plugins/tile_map/public/base_maps_visualization.js @@ -27,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. @@ -195,7 +195,9 @@ export function BaseMapsVisualizationProvider(serviceSettings) { } async _updateData() { - throw new Error('Child should implement this method to respond to data-update'); + throw new Error(i18n('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 44e25f538dc1e..fef5d5cbfab97 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'; @@ -219,7 +220,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 23c580953dbdf..a0d9b008e3b9e 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,15 +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/editors/wms_options.js b/src/core_plugins/tile_map/public/editors/wms_options.js index 067b7efffb721..47c379b255e10 100644 --- a/src/core_plugins/tile_map/public/editors/wms_options.js +++ b/src/core_plugins/tile_map/public/editors/wms_options.js @@ -21,7 +21,7 @@ import { uiModules } from 'ui/modules'; import wmsOptionsTemplate from './wms_options.html'; const module = uiModules.get('kibana'); -module.directive('wmsOptions', function (serviceSettings) { +module.directive('wmsOptions', function (serviceSettings, i18n) { return { restrict: 'E', template: wmsOptionsTemplate, @@ -31,6 +31,7 @@ module.directive('wmsOptions', function (serviceSettings) { collections: '=', }, link: function ($scope) { + $scope.wmsLinkText = i18n('tileMap.wmsOptions.wmsLinkText', { defaultMessage: 'here' }); new Promise((resolve, reject) => { 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..670af56e76f65 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.mapDescription', { + 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