Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(measure): ft tooltip to pi for french translation #572

Merged
merged 1 commit into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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²": "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²": "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