diff --git a/packages/geo/src/lib/measure/measurer/measurer.component.ts b/packages/geo/src/lib/measure/measurer/measurer.component.ts index 81972dfe42..c0d1f4b82c 100644 --- a/packages/geo/src/lib/measure/measurer/measurer.component.ts +++ b/packages/geo/src/lib/measure/measurer/measurer.component.ts @@ -860,7 +860,7 @@ export class MeasurerComponent implements OnInit, OnDestroy { unit: properties._unit, unitAbbr: true, locale: 'fr' - }); + }, this.languageService); } /** diff --git a/packages/geo/src/lib/measure/shared/measure.utils.ts b/packages/geo/src/lib/measure/shared/measure.utils.ts index 37576c97c5..ca2be39810 100644 --- a/packages/geo/src/lib/measure/shared/measure.utils.ts +++ b/packages/geo/src/lib/measure/shared/measure.utils.ts @@ -1,3 +1,4 @@ +import { LanguageService } from '@igo2/core'; import * as olstyle from 'ol/style'; import OlGeometry from 'ol/geom/Geometry'; import OlPoint from 'ol/geom/Point'; @@ -134,12 +135,15 @@ export function squareMetersToUnit(value: number, unit: MeasureAreaUnit): number * @param options Formatting options * @returns Formatted measure */ -export function formatMeasure(measure: number, options?: { - decimal?: number; - unit?: MeasureAreaUnit | MeasureLengthUnit; - unitAbbr?: boolean; - locale?: string; -}) { +export function formatMeasure( + measure: number, + options?: { + decimal?: number; + unit?: MeasureAreaUnit | MeasureLengthUnit; + unitAbbr?: boolean; + locale?: string; + }, + languageService?: LanguageService) { let decimal = options.decimal; if (decimal === undefined || decimal < 0) { decimal = 1; @@ -156,10 +160,17 @@ export function formatMeasure(measure: number, options?: { } if (options.unit !== undefined && options.unitAbbr === true) { - parts.push( - MeasureLengthUnitAbbreviation[options.unit] || - MeasureAreaUnitAbbreviation[options.unit] - ); + if (languageService) { + parts.push( + MeasureLengthUnitAbbreviation[options.unit] ? + languageService.translate.instant('igo.geo.measure.' + MeasureLengthUnitAbbreviation[options.unit]) : + languageService.translate.instant('igo.geo.measure.' + MeasureAreaUnitAbbreviation[options.unit]) + ); + } else { + parts.push( + MeasureLengthUnitAbbreviation[options.unit] || MeasureAreaUnitAbbreviation[options.unit] + ); + } } return parts.filter(p => p !== undefined).join(' '); diff --git a/packages/geo/src/locale/en.geo.json b/packages/geo/src/locale/en.geo.json index cbf0a6760a..e002b06e35 100644 --- a/packages/geo/src/locale/en.geo.json +++ b/packages/geo/src/locale/en.geo.json @@ -416,15 +416,25 @@ "lengthHeader": "Length / Perimeter", "perimeter": "Perimeter", "meters": "Meters", + "m": "m", "kilometers": "Kilometers", + "km": "km", "miles": "Miles", + "mi": "mi", "feet": "Feet", + "ft": "ft", "squareMeters": "Meters²", + "m²": "m²", "squareKilometers": "Kilometers²", + "km²": "km²", "squareMiles": "Miles²", + "mi²": "mi²", "squareFeet": "Feet²", + "ft²": "ft²", "hectares": "Hectares", + "ha": "ha", "acres": "Acres", + "ac": "ac", "toggleActive": "Activate measures", "toggleMapTooltips": "Show map tooltips", "toggleAutoUnits": "Auto Units", diff --git a/packages/geo/src/locale/fr.geo.json b/packages/geo/src/locale/fr.geo.json index d35220437a..830f0605d3 100644 --- a/packages/geo/src/locale/fr.geo.json +++ b/packages/geo/src/locale/fr.geo.json @@ -417,15 +417,25 @@ "lengthHeader": "Distance / Périmètre", "perimeter": "Périmètre", "meters": "Mètres", + "m": "m", "kilometers": "Kilomètres", + "km": "km", "miles": "Miles", + "mi": "mi", "feet": "Pieds", + "ft": "pi", "squareMeters": "Mètres²", + "m²": "m²", "squareKilometers": "Kilomètres²", + "km²": "km²", "squareMiles": "Miles²", + "mi²": "mi²", "squareFeet": "Pieds²", + "ft²": "pi²", "hectares": "Hectares", + "ha": "ha", "acres": "Acres", + "ac": "ac", "toggleActive": "Activer le contrôle de mesure", "toggleMapTooltips": "Mesures sur la carte", "toggleAutoUnits": "Unités automatiques",