Skip to content

Commit

Permalink
feat: improve language detection in ExportControl
Browse files Browse the repository at this point in the history
  • Loading branch information
nimdanitro committed Aug 20, 2024
1 parent 03ff112 commit e991d01
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion ui/src/views/map/controls/ExportControl.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Format, MaplibreExportControl, PageOrientation, Size } from "@watergis/maplibre-gl-export";
import { Language, Format, MaplibreExportControl, PageOrientation, Size } from "@watergis/maplibre-gl-export";
import '@watergis/maplibre-gl-export/dist/maplibre-gl-export.css';
import i18next from "i18next";
import { ControlPosition, useControl } from "react-map-gl/maplibre";

export type ExportControlProps = {
Expand All @@ -8,6 +9,18 @@ export type ExportControlProps = {
// options: ConstructorParameters<typeof MapboxExportControl>
};

function getLanguage(): Language {
switch (i18next.language) {
case "de":
return "de"
case "fr":
return "fr"

default:
return "en"
}
}

function ExportControl(props: ExportControlProps): null {
const { position } = props;
useControl<MaplibreExportControl>(
Expand All @@ -19,6 +32,18 @@ function ExportControl(props: ExportControlProps): null {
DPI: 300,
Crosshair: false,
PrintableArea: true,
Local: getLanguage(),
attributionOptions: {
style: {
"textSize": 16,
"textHaloColor": "#FFFFFF",
"textHaloWidth": 0.8,
"textColor": "#000000",
"fallbackTextFont": ["B612 Mono"]
},
visibility: "visible",
position: "bottom-right"
}
}),
{ position: position }
);
Expand Down

0 comments on commit e991d01

Please sign in to comment.