From d30bf27bc833118dcf8415998bb292ce82f0760d Mon Sep 17 00:00:00 2001 From: Pavel Date: Thu, 4 Oct 2018 15:28:10 +0300 Subject: [PATCH 1/5] add translations for region_map plugin --- .i18nrc.json | 1 + .../region_map/public/choropleth_layer.js | 24 +++-- .../region_map/public/region_map_vis.js | 20 ++-- .../public/region_map_vis_params.html | 95 +++++++++++++------ .../public/region_map_visualization.js | 17 +++- 5 files changed, 110 insertions(+), 47 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index 8ac1cf0fbd1ea..a7cc0a1fcbab9 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -5,6 +5,7 @@ "kbn": "src/core_plugins/kibana", "markdownVis": "src/core_plugins/markdown_vis", "metricVis": "src/core_plugins/metric_vis", + "regionMap": "src/core_plugins/region_map", "statusPage": "src/core_plugins/status_page", "xpack.idxMgmt": "x-pack/plugins/index_management" }, diff --git a/src/core_plugins/region_map/public/choropleth_layer.js b/src/core_plugins/region_map/public/choropleth_layer.js index 79171e58a4e4d..bf76c520b92be 100644 --- a/src/core_plugins/region_map/public/choropleth_layer.js +++ b/src/core_plugins/region_map/public/choropleth_layer.js @@ -21,6 +21,7 @@ import $ from 'jquery'; import L from 'leaflet'; import _ from 'lodash'; import d3 from 'd3'; +import { i18n } from '@kbn/i18n'; import { KibanaMapLayer } from 'ui/vis/map/kibana_map_layer'; import { truncatedColorMaps } from 'ui/vislib/components/color/truncated_colormaps'; import * as topojson from 'topojson-client'; @@ -123,7 +124,10 @@ export default class ChoroplethLayer extends KibanaMapLayer { featureCollection = topojson.feature(data, features);//conversion to geojson } else { //should never happen - throw new Error('Unrecognized format ' + formatType); + throw new Error(i18n.translate('regionMap.choroplethLayer.unrecognizedFormatErrorMessage', { + defaultMessage: 'Unrecognized format {formatType}', + values: { formatType }, + })); } this._sortedFeatures = featureCollection.features.slice(); this._sortFeatures(); @@ -143,15 +147,23 @@ export default class ChoroplethLayer extends KibanaMapLayer { let errorMessage; if (e.status === 404) { - errorMessage = `Server responding with '404' when attempting to fetch ${geojsonUrl}. - Make sure the file exists at that location.`; + errorMessage = i18n.translate('regionMap.choroplethLayer.downloadingVectorData404ErrorMessage', { + defaultMessage: 'Server responding with \'404\' when attempting to fetch {geojsonUrl}. \ +Make sure the file exists at that location.', + values: { geojsonUrl }, + }); } else { - errorMessage = `Cannot download ${geojsonUrl} file. Please ensure the -CORS configuration of the server permits requests from the Kibana application on this host.`; + errorMessage = i18n.translate('regionMap.choroplethLayer.downloadingVectorDataErrorMessage', { + defaultMessage: 'Cannot download {geojsonUrl} file. Please ensure the \ +CORS configuration of the server permits requests from the Kibana application on this host.', + values: { geojsonUrl }, + }); } toastNotifications.addDanger({ - title: 'Error downloading vector data', + title: i18n.translate('regionMap.choroplethLayer.downloadingVectorDataErrorMessageTitle', { + defaultMessage: 'Error downloading vector data', + }), text: errorMessage, }); diff --git a/src/core_plugins/region_map/public/region_map_vis.js b/src/core_plugins/region_map/public/region_map_vis.js index 2fde449c6bb8b..c48e9a02718e6 100644 --- a/src/core_plugins/region_map/public/region_map_vis.js +++ b/src/core_plugins/region_map/public/region_map_vis.js @@ -28,7 +28,7 @@ import { mapToLayerWithId } from './util'; import { RegionMapsVisualizationProvider } from './region_map_visualization'; import { Status } from 'ui/vis/update_status'; -VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmapsConfig, config) { +VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmapsConfig, config, i18n) { const VisFactory = Private(VisFactoryProvider); const RegionMapsVisualization = Private(RegionMapsVisualizationProvider); @@ -38,9 +38,9 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps return VisFactory.createBaseVisualization({ name: 'region_map', - title: 'Region Map', - description: 'Show metrics on a thematic map. Use one of the provided base maps, or add your own. ' + - 'Darker colors represent higher values.', + title: i18n('regionMap.mapVis.regionMapTitle', { defaultMessage: 'Region Map' }), + description: i18n('regionMap.mapVis.regionMapDescription', { defaultMessage: 'Show metrics on a thematic map. Use one of the \ +provided base maps, or add your own. Darker colors represent higher values.' }), category: CATEGORY.MAP, icon: 'visMapRegion', visConfig: { @@ -66,16 +66,16 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps collections: { legendPositions: [{ value: 'bottomleft', - text: 'bottom left', + text: i18n('regionMap.mapVis.regionMapEditorConfig.bottomLeftText', { defaultMessage: 'bottom left' }), }, { value: 'bottomright', - text: 'bottom right', + text: i18n('regionMap.mapVis.regionMapEditorConfig.bottomRightText', { defaultMessage: 'bottom right' }), }, { value: 'topleft', - text: 'top left', + text: i18n('regionMap.mapVis.regionMapEditorConfig.topLeftText', { defaultMessage: 'top left' }), }, { value: 'topright', - text: 'top right', + text: i18n('regionMap.mapVis.regionMapEditorConfig.topRightText', { defaultMessage: 'top right' }), }], colorSchemas: Object.keys(truncatedColorMaps), vectorLayers: vectorLayers @@ -84,7 +84,7 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps { group: 'metrics', name: 'metric', - title: 'Value', + title: i18n('regionMap.mapVis.regionMapEditorConfig.schemas.metricTitle', { defaultMessage: 'Value' }), min: 1, max: 1, aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality', 'top_hits', @@ -97,7 +97,7 @@ VisTypesRegistryProvider.register(function RegionMapProvider(Private, regionmaps group: 'buckets', name: 'segment', icon: 'fa fa-globe', - title: 'shape field', + title: i18n('regionMap.mapVis.regionMapEditorConfig.schemas.segmentTitle', { defaultMessage: 'shape field' }), min: 1, max: 1, aggFilter: ['terms'] diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 997050e3f8c5d..00c8d98b8ea6f 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -1,15 +1,20 @@
-
- Layer Settings -
+
- +
- + +
- +
 
- +
 
@@ -79,12 +108,19 @@
-
Style settings
+
- +
0 && shouldShowWarning) { toastNotifications.addWarning({ - title: `Unable to show ${event.mismatches.length} ${event.mismatches.length > 1 ? 'results' : 'result'} on map`, - text: `Ensure that each of these term matches a shape on that shape's join field: ${event.mismatches.join(', ')}`, + title: i18n('regionMap.visualization.unableToShowMismatchesWarningTitle', { + defaultMessage: 'Unable to show {mismatchesLength} {oneMismatch, plural, one {result} other {results}} on map', + values: { + mismatchesLength: event.mismatches.length, + oneMismatch: event.mismatches.length > 1 ? 0 : 1, + }, + }), + text: i18n('regionMap.visualization.unableToShowMismatchesWarningText', { + defaultMessage: 'Ensure that each of these term matches a shape on that shape\'s join field: {mismatches}', + values: { + mismatches: event.mismatches.join(', '), + }, + }), }); } }); From 616276317b4b3d56c6b82c79fb27005892bc4150 Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 5 Oct 2018 15:29:52 +0300 Subject: [PATCH 2/5] refactoring --- .../public/region_map_vis_params.html | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 00c8d98b8ea6f..c17b33582dfc9 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -27,20 +27,20 @@
- +
@@ -77,9 +77,9 @@  
@@ -96,8 +96,8 @@  
From 749de6a038c5a21ee0085f3f2af46795927b6785 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 24 Oct 2018 18:21:37 +0300 Subject: [PATCH 3/5] fix quotes --- .../region_map/public/region_map_vis_params.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 00973e09e39cc..a8cb7e9a4fd9a 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -77,8 +77,7 @@   @@ -96,7 +95,7 @@   From 75177da1bd2c9914ae24de17261eaf5d2872d358 Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 26 Oct 2018 12:55:11 +0300 Subject: [PATCH 4/5] move translated text to separate span tag --- .../region_map/public/region_map_vis_params.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index a8cb7e9a4fd9a..026c5280ffe48 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -37,10 +37,13 @@ defaultMessage: 'Preview {selectedLayerName} on the Elastic Maps Service', values: { selectedLayerName: editorState.params.selectedLayer.name } } }}" - i18n-id="regionMap.visParams.previewOnEMSLinkText" - i18n-default-message="{icon} Preview on EMS" - i18n-values="{ icon: '' }" - > + > + + +
From 6f7c68546ad22658ecc9e7d0fc2fd4d532ceb2ff Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 26 Oct 2018 17:13:14 +0300 Subject: [PATCH 5/5] fix quotes --- src/core_plugins/region_map/public/region_map_vis_params.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core_plugins/region_map/public/region_map_vis_params.html b/src/core_plugins/region_map/public/region_map_vis_params.html index 026c5280ffe48..58be7df7a739a 100644 --- a/src/core_plugins/region_map/public/region_map_vis_params.html +++ b/src/core_plugins/region_map/public/region_map_vis_params.html @@ -80,7 +80,7 @@   @@ -98,7 +98,7 @@