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

feat: new translations #46

Merged
merged 2 commits into from
Dec 23, 2023
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
5 changes: 5 additions & 0 deletions .changeset/poor-fishes-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@watergis/maplibre-gl-export": minor
---

feat: add Japanese language (ja)
5 changes: 5 additions & 0 deletions .changeset/pretty-planes-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@watergis/maplibre-gl-export": minor
---

feat: bring new translations (Vietnam, Ukranian, Chinese simplified and Chinese traditional) from mapbox-gl-export
5 changes: 5 additions & 0 deletions packages/maplibre-gl-export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ You can specify default option as follows.
- `fi` finnish
- `sv` swedish
- `es` spanish
- `vi` Vietnam
- `uk` Ukranian
- `zhHans` Chinese Simplified
- `zhHant` Chinese Traditional
- `ja` Japanese
- AllowedSizes
- list of allowed page sizes for export
- available values `'A2'`, `'A3'`, `'A4'`, `'A5'`, `'A6'`, `'B2'`, `'B3'`, `'B4'`, `'B5'`, `'B6'`
Expand Down
27 changes: 25 additions & 2 deletions packages/maplibre-gl-export/src/lib/export-control.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import { ControlPosition, IControl, Map as MaplibreMap } from 'maplibre-gl';
import CrosshairManager from './crosshair-manager';
import PrintableAreaManager from './printable-area-manager';
import { english, french, finnish, german, swedish, spanish, Translation } from './local';
import {
english,
french,
finnish,
german,
swedish,
spanish,
vietnam,
ukranian,
zhHans,
zhHant,
ja,
Translation
} from './local';
import MapGenerator, { Size, Format, PageOrientation, DPI, Unit } from './map-generator';

type Options = {
Expand All @@ -11,7 +24,7 @@ type Options = {
DPI?: number;
Crosshair?: boolean;
PrintableArea?: boolean;
Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'es';
Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'es' | 'vi' | 'uk' | 'zhHans' | 'zhHant' | 'ja';
AllowedSizes?: ('A2' | 'A3' | 'A4' | 'A5' | 'A6' | 'B2' | 'B3' | 'B4' | 'B5' | 'B6')[];
Filename?: string;
};
Expand Down Expand Up @@ -82,6 +95,16 @@ export default class MaplibreExportControl implements IControl {
return swedish;
case 'es':
return spanish;
case 'vi':
return vietnam;
case 'uk':
return ukranian;
case 'zhHans':
return zhHans;
case 'zhHant':
return zhHant;
case 'ja':
return ja;
default:
return english;
}
Expand Down
20 changes: 19 additions & 1 deletion packages/maplibre-gl-export/src/lib/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import finnish from './fi';
import german from './de';
import swedish from './sv';
import spanish from './es';
import vietnam from './vi';
import ukranian from './uk';
import zhHans from './zhHans';
import zhHant from './zhHant';
import ja from './ja';

type Translation = {
PageSize: string;
Expand All @@ -13,4 +18,17 @@ type Translation = {
Generate: string;
};

export { english, french, finnish, german, swedish, spanish, Translation };
export {
english,
french,
finnish,
german,
swedish,
spanish,
vietnam,
ukranian,
zhHans,
zhHant,
ja,
Translation
};
9 changes: 9 additions & 0 deletions packages/maplibre-gl-export/src/lib/local/ja.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const translation = {
PageSize: 'ページサイズ',
PageOrientation: 'ページ方向',
Format: 'フォーマット',
DPI: 'DPI(解像度)',
Generate: '出力'
};

export default translation;
9 changes: 9 additions & 0 deletions packages/maplibre-gl-export/src/lib/local/uk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const translation = {
PageSize: 'Розмір сторінки',
PageOrientation: 'Орієнтація сторінки',
Format: 'Формат',
DPI: 'DPI',
Generate: 'Згенерувати'
};

export default translation;
9 changes: 9 additions & 0 deletions packages/maplibre-gl-export/src/lib/local/vi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const translation = {
PageSize: 'Kích thước trang',
PageOrientation: 'Loại trang',
Format: 'Định dạng',
DPI: 'Mật độ điểm ảnh (DPI)',
Generate: 'Tạo'
};

export default translation;
9 changes: 9 additions & 0 deletions packages/maplibre-gl-export/src/lib/local/zhHans.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const translation = {
PageSize: '页面大小',
PageOrientation: '页面方向',
Format: '格式',
DPI: '像素',
Generate: '导出'
};

export default translation;
9 changes: 9 additions & 0 deletions packages/maplibre-gl-export/src/lib/local/zhHant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const translation = {
PageSize: '頁面大小',
PageOrientation: '頁面方向',
Format: '格式',
DPI: '像素',
Generate: '導出'
};

export default translation;
30 changes: 30 additions & 0 deletions sites/maplibre-gl-export.water-gis.com/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
rel="stylesheet"
href="node_modules/@watergis/maplibre-gl-export/dist/maplibre-gl-export.css"
/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" />
<style>
body {
margin: 0;
Expand All @@ -24,6 +25,13 @@
width: 100%;
z-index: 10;
}
.overlay {
position: absolute;
top: 10px;
right: 60px;
background-color: white;
z-index: 10;
}
</style>
</head>
<body>
Expand All @@ -35,6 +43,28 @@
>Fork me on GitHub</a
>
<div id="map"></div>
<div class="overlay p-2">
<div class="field">
<label class="label">Select a language</label>
<div class="control">
<div class="select is-medimum">
<select id="language">
<option value="en">English</option>
<option value="fr">French</option>
<option value="fi">Finish</option>
<option value="de">German</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="vi">Vietnam</option>
<option value="uk">Ukranian</option>
<option value="zhHans">Chinese simplified</option>
<option value="zhHant">Chinese traditional</option>
<option value="ja">Japanese</option>
</select>
</div>
</div>
</div>
</div>
<script type="module" src="src/index.js"></script>
</body>
</html>
34 changes: 28 additions & 6 deletions sites/maplibre-gl-export.water-gis.com/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,37 @@ const map = new Map({
hash: true
});
map.addControl(new NavigationControl({}), 'top-right');
map.addControl(
new MaplibreExportControl({

const languageOption = document.getElementById('language');
languageOption.value = 'en';

let exportControl = new MaplibreExportControl({
PageSize: Size.A3,
PageOrientation: PageOrientation.Portrait,
Format: Format.PNG,
DPI: DPI[96],
Crosshair: true,
PrintableArea: true,
Local: languageOption.value
});

map.addControl(exportControl, 'top-right');

languageOption.addEventListener('change', () => {
if (exportControl) {
map.removeControl(exportControl);
}

const language = document.getElementById('language');
exportControl = new MaplibreExportControl({
PageSize: Size.A3,
PageOrientation: PageOrientation.Portrait,
Format: Format.PNG,
DPI: DPI[96],
Crosshair: true,
PrintableArea: true,
Local: 'en'
}),
'top-right'
);
Local: language.value
});

map.addControl(exportControl, 'top-right');
});