Skip to content

Commit

Permalink
fix(measure): ft tooltip to pi for french translation (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeLafreniere18 committed Jan 31, 2020
1 parent 0595837 commit e40495e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export class MeasurerComponent implements OnInit, OnDestroy {
unit: properties._unit,
unitAbbr: true,
locale: 'fr'
});
}, this.languageService);
}

/**
Expand Down
31 changes: 21 additions & 10 deletions packages/geo/src/lib/measure/shared/measure.utils.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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(' ');
Expand Down
10 changes: 10 additions & 0 deletions packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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²": "",
"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",
Expand Down
10 changes: 10 additions & 0 deletions packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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²": "",
"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",
Expand Down

0 comments on commit e40495e

Please sign in to comment.