Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Added ukrainian language (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalii Feduniak <[email protected]>
Co-authored-by: Jin Igarashi <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2023
1 parent 69b9993 commit f5032e7
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 19 deletions.
92 changes: 74 additions & 18 deletions lib/export-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ import { IControl, Map as MapboxMap } from 'mapbox-gl';
import CrosshairManager from './crosshair-manager';
import PrintableAreaManager from './printable-area-manager';
import {
english, finnish, french, german, swedish, Translation, vietnam, zhHans, zhHant
english,
finnish,
french,
german,
swedish,
Translation,
vietnam,
ukranian,
zhHans,
zhHant
} from './local';
import MapGenerator, {
Size, Format, PageOrientation, DPI, Unit,
Size,
Format,
PageOrientation,
DPI,
Unit,
} from './map-generator';

type Options = {
Expand All @@ -16,8 +29,8 @@ type Options = {
Crosshair?: boolean;
PrintableArea: boolean;
accessToken?: string;
Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'vi' | 'zhHans' | 'zhHant';
}
Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'vi' | 'uk' | 'zhHans' | 'zhHant';
};

/**
* Mapbox GL Export Control.
Expand Down Expand Up @@ -72,6 +85,8 @@ export default class MapboxExportControl implements IControl {
return swedish;
case 'vi':
return vietnam;
case 'uk':
return ukranian;
case 'zhHans':
return zhHans;
case 'zhHant':
Expand Down Expand Up @@ -105,16 +120,40 @@ export default class MapboxExportControl implements IControl {
const table = document.createElement('TABLE');
table.className = 'print-table';

const tr1 = this.createSelection(Size, this.getTranslation().PageSize, 'page-size', this.options.PageSize, (data, key) => JSON.stringify(data[key]));
const tr1 = this.createSelection(
Size,
this.getTranslation().PageSize,
'page-size',
this.options.PageSize,
(data, key) => JSON.stringify(data[key]),
);
table.appendChild(tr1);

const tr2 = this.createSelection(PageOrientation, this.getTranslation().PageOrientation, 'page-orientaiton', this.options.PageOrientation, (data, key) => data[key]);
const tr2 = this.createSelection(
PageOrientation,
this.getTranslation().PageOrientation,
'page-orientaiton',
this.options.PageOrientation,
(data, key) => data[key],
);
table.appendChild(tr2);

const tr3 = this.createSelection(Format, this.getTranslation().Format, 'format-type', this.options.Format, (data, key) => data[key]);
const tr3 = this.createSelection(
Format,
this.getTranslation().Format,
'format-type',
this.options.Format,
(data, key) => data[key],
);
table.appendChild(tr3);

const tr4 = this.createSelection(DPI, this.getTranslation().DPI, 'dpi-type', this.options.DPI, (data, key) => data[key]);
const tr4 = this.createSelection(
DPI,
this.getTranslation().DPI,
'dpi-type',
this.options.DPI,
(data, key) => data[key],
);
table.appendChild(tr4);

this.exportContainer.appendChild(table);
Expand All @@ -124,10 +163,18 @@ export default class MapboxExportControl implements IControl {
generateButton.textContent = this.getTranslation().Generate;
generateButton.classList.add('generate-button');
generateButton.addEventListener('click', () => {
const pageSize: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-page-size');
const pageOrientation: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-page-orientaiton');
const formatType: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-format-type');
const dpiType: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-dpi-type');
const pageSize: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-page-size')
);
const pageOrientation: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-page-orientaiton')
);
const formatType: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-format-type')
);
const dpiType: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-dpi-type')
);
const orientValue = pageOrientation.value;
let pageSizeValue = JSON.parse(pageSize.value);
if (orientValue === PageOrientation.Portrait) {
Expand Down Expand Up @@ -171,7 +218,9 @@ export default class MapboxExportControl implements IControl {
}
content.appendChild(optionLayout);
});
content.addEventListener('change', () => { this.updatePrintableArea(); });
content.addEventListener('change', () => {
this.updatePrintableArea();
});

const tr1 = document.createElement('TR');
const tdLabel = document.createElement('TD');
Expand All @@ -184,10 +233,12 @@ export default class MapboxExportControl implements IControl {
}

public onRemove(): void {
if (!this.controlContainer
if (
!this.controlContainer
|| !this.controlContainer.parentNode
|| !this.map
|| !this.exportButton) {
|| !this.exportButton
) {
return;
}
this.exportButton.removeEventListener('click', this.onDocumentClick);
Expand All @@ -207,7 +258,8 @@ export default class MapboxExportControl implements IControl {
this.controlContainer
&& !this.controlContainer.contains(event.target as Element)
&& this.exportContainer
&& this.exportButton) {
&& this.exportButton
) {
this.exportContainer.style.display = 'none';
this.exportButton.style.display = 'block';
this.toggleCrosshair(false);
Expand Down Expand Up @@ -247,8 +299,12 @@ export default class MapboxExportControl implements IControl {
if (this.printableArea === undefined) {
return;
}
const pageSize: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-page-size');
const pageOrientation: HTMLSelectElement = <HTMLSelectElement>document.getElementById('mapbox-gl-export-page-orientaiton');
const pageSize: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-page-size')
);
const pageOrientation: HTMLSelectElement = <HTMLSelectElement>(
document.getElementById('mapbox-gl-export-page-orientaiton')
);
const orientValue = pageOrientation.value;
let pageSizeValue = JSON.parse(pageSize.value);
if (orientValue === PageOrientation.Portrait) {
Expand Down
4 changes: 3 additions & 1 deletion lib/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import finnish from './fi';
import german from './de';
import swedish from './sv';
import vietnam from './vi';
import ukranian from './uk';
import zhHans from './zhHans';
import zhHant from './zhHant';

Expand All @@ -13,7 +14,7 @@ type Translation = {
Format: string;
DPI: string;
Generate: string;
}
};

export {
english,
Expand All @@ -22,6 +23,7 @@ export {
german,
swedish,
vietnam,
ukranian,
zhHans,
zhHant,
Translation,
Expand Down
9 changes: 9 additions & 0 deletions 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;

0 comments on commit f5032e7

Please sign in to comment.