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

add ts support for i18n strings #217

Merged
merged 17 commits into from
Feb 4, 2025
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
84 changes: 84 additions & 0 deletions @types/i18next.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import 'i18next'

// // // core/plugins // // //

import { resourcesDe as resourcesDeCore } from '@polar/core/src/locales'
import { resourcesDe as resourcesDeAddressSearch } from '@polar/plugin-address-search/src/locales'
import { resourcesDe as resourcesDeAttributions } from '@polar/plugin-attributions/src/locales'
import { resourcesDe as resourcesDeDraw } from '@polar/plugin-draw/src/locales'
import { resourcesDe as resourcesDeExport } from '@polar/plugin-export/src/locales'
import { resourcesDe as resourcesDeFilter } from '@polar/plugin-filter/src/locales'
import { resourcesDe as resourcesDeFullscreen } from '@polar/plugin-fullscreen/src/locales'
import { resourcesDe as resourcesDeGeoLocation } from '@polar/plugin-geo-location/src/locales'
import { resourcesDe as resourcesDeGfi } from '@polar/plugin-gfi/src/locales'
import { resourcesDe as resourcesDeIconMenu } from '@polar/plugin-icon-menu/src/locales'
import { resourcesDe as resourcesDeLayerChooser } from '@polar/plugin-layer-chooser/src/locales'
import { resourcesDe as resourcesDeLegend } from '@polar/plugin-legend/src/locales'
import { resourcesDe as resourcesDeLoadingIndicator } from '@polar/plugin-loading-indicator/src/locales'
import { resourcesDe as resourcesDePins } from '@polar/plugin-pins/src/locales'
import { resourcesDe as resourcesDeScale } from '@polar/plugin-scale/src/locales'
import { resourcesDe as resourcesDeToast } from '@polar/plugin-toast/src/locales'
import { resourcesDe as resourcesDeZoom } from '@polar/plugin-zoom/src/locales'

// // // clients // // //

import { dishDe } from '@polar/client-dish/src/locales'
import { dishHeaderDe } from '@polar/client-dish/src/plugins/Header/locales'
import { dishModalDe } from '@polar/client-dish/src/plugins/Modal/locales'
import { meldemichelDe } from '@polar/client-meldemichel/src/locales'
import { meldemichelDe as meldemichelAfmButtonDe } from '@polar/client-meldemichel/src/plugins/AfmButton/locales'
import { snowboxDe } from '@polar/client-snowbox/src/locales'
import { textLocatorDe } from '@polar/client-text-locator/src/locales'
import { textLocatorDe as textLocatorHeaderDe } from '@polar/client-text-locator/src/plugins/Header/locales'
import { geometrySearchDe } from '@polar/client-text-locator/src/plugins/GeometrySearch/locales'

// // // resources // // //

const resources = {
common: {
...resourcesDeCore,
dish: dishDe,
meldemichel: meldemichelDe,
snowbox: snowboxDe,
textLocator: textLocatorDe,
plugins: {
addressSearch: resourcesDeAddressSearch.plugins.addressSearch,
attributions: resourcesDeAttributions.plugins.attributions,
dish: {
...dishHeaderDe,
...dishModalDe
},
draw: resourcesDeDraw.plugins.draw,
export: resourcesDeExport.plugins.export,
filter: resourcesDeFilter.plugins.filter,
fullscreen: resourcesDeFullscreen.plugins.fullscreen,
geoLocation: resourcesDeGeoLocation.plugins.geoLocation,
// geometrySearch is from textLocator
geometrySearch: {
...geometrySearchDe
},
gfi: resourcesDeGfi.plugins.gfi,
iconMenu: resourcesDeIconMenu.plugins.iconMenu,
layerChooser: resourcesDeLayerChooser.plugins.layerChooser,
legend: resourcesDeLegend.plugins.legend,
loadingIndicator: resourcesDeLoadingIndicator.plugins.loadingIndicator,
meldemichel: {
...meldemichelAfmButtonDe
},
pins: resourcesDePins.plugins.pins,
scale: resourcesDeScale.plugins.scale,
textLocator: {
...textLocatorHeaderDe
},
toast: resourcesDeToast.plugins.toast,
zoom: resourcesDeZoom.plugins.zoom,
}
}
} as const

declare module 'i18next' {
interface CustomTypeOptions {
defaultNS: "common"
resources: typeof resources
}
}
3 changes: 0 additions & 3 deletions packages/clients/afm/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/clients/dish/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fix: Extend typing for search result function according to type package update.
- Fix: Import types `AddressSearchState` and `AddressSearchGetters` from correct position.
- Fix: Import enum `SearchResultSymbols` from correct position.
- Fix: The alt text to the "Landesdachmarke" for screen readers was missing.
- Chore: Change value of `pins.movable` configuration to `'drag'` as using a boolean has been deprecated in a future release.
- Chore: Upgrade `@masterportal/masterportalapi` from `2.8.0` to `2.45.0` and subsequently `ol` from `^7.1.0` to `^10.3.1`.
- Chore: Update `@polar`-dependencies to the latest versions.
Expand Down
49 changes: 0 additions & 49 deletions packages/clients/dish/src/language.ts

This file was deleted.

54 changes: 54 additions & 0 deletions packages/clients/dish/src/locales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Locale } from '@polar/lib-custom-types'

export const dishDe = {
backendSizeError:
'Die Suche ist zu allgemein. Bitte wählen Sie weitere Suchbegriffe oder schränken Sie die Suche über einen Filter ein.',
unknownError: 'Ein unbekannter Fehler ist aufgetreten.',
idNotFound:
'Die verlinkte ID konnte leider nicht aufgelöst werden. Bitte verwenden Sie Suche und Karte, um zum Denkmal zu navigieren.',
addressSearchHint: 'Eingabe von z.B. Bezeichnung, Lage, Adresse, ...',
} as const

export const resourcesDe = {
dish: dishDe,
plugins: {
gfi: {
property: {
export: 'Export Detailinformationen',
},
toggle: 'Informationen zu Sachgesamtheit öffnen/schließen',
},
},
} as const

export const resourcesEn = {
dish: {
backendSizeError:
'Too broad search. Please choose additional search terms or use a filter.',
unknownError: 'An unknown error occurred.',
idNotFound:
'The linked ID could not be found. Please use the search function or map to navigate to your point of interest.',
addressSearchHint: 'Entry of e.g. monument names, location, address, ...',
},
plugins: {
gfi: {
property: {
export: 'Detail information export',
},
toggle: 'Open/close additional information',
},
},
} as const

const locales: Locale[] = [
{
type: 'de',
resources: resourcesDe,
},
{
type: 'en',
resources: resourcesEn,
},
]

export default locales
4 changes: 2 additions & 2 deletions packages/clients/dish/src/mapConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
dishBaseUrl,
// servicePrefix, s.u.
} from './services'
import locales from './language'
import locales from './locales'

const shBlue = '#003064'
const shWhite = '#FFFFFF'
Expand Down Expand Up @@ -171,7 +171,7 @@ export const mapConfiguration = {
groupProperties: {
groupDenkmalsuche: {
label: 'Denkmalsuche',
hint: 'common:dish.addressSearchHint',
hint: 'dish.addressSearchHint',
resultDisplayMode: 'categorized',
limitResults: 3,
},
Expand Down
8 changes: 4 additions & 4 deletions packages/clients/dish/src/plugins/Gfi/ActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
text
:href="exportProperty"
target="_blank"
:alt="$t('common:plugins.gfi.property.imageAlt')"
:title="$t('common:plugins.gfi.property.linkTitle')"
:aria-label="$t('common:plugins.gfi.property.export')"
:alt="$t('plugins.gfi.property.imageAlt')"
:title="$t('plugins.gfi.property.linkTitle')"
:aria-label="$t('plugins.gfi.property.export')"
onmousedown="return false"
>
<v-icon small>fa-download</v-icon>
{{ $t('common:plugins.gfi.property.export') }}
{{ $t('plugins.gfi.property.export') }}
</v-btn>
</template>

Expand Down
4 changes: 2 additions & 2 deletions packages/clients/dish/src/plugins/Gfi/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<v-btn
icon
small
:aria-label="$t('common:plugins.gfi.header.close')"
:aria-label="$t('plugins.gfi.header.close')"
@click="close(true)"
>
<v-icon small>fa-xmark</v-icon>
Expand Down Expand Up @@ -49,7 +49,7 @@
<v-btn
icon
x-small
:aria-label="$t('common:plugins.gfi.toggle')"
:aria-label="$t('plugins.gfi.toggle')"
@click="toggleSachgesamtheit"
>
<v-icon small>
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/dish/src/plugins/Header/Header.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<h1 class="polar-plugin-header">
{{ $t('common:plugins.dish.header.text') }}
{{ $t('plugins.dish.header.text') }}
</h1>
</template>

Expand Down
4 changes: 2 additions & 2 deletions packages/clients/dish/src/plugins/Header/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Vue from 'vue'
import { PluginOptions } from '@polar/lib-custom-types'
import Header from './Header.vue'
import language from './language'
import locales from './locales'

export default (options: PluginOptions) => (instance: Vue) =>
instance.$store.dispatch('addComponent', {
name: 'header',
plugin: Header,
language,
locales,
options,
})
28 changes: 0 additions & 28 deletions packages/clients/dish/src/plugins/Header/language.ts

This file was deleted.

32 changes: 32 additions & 0 deletions packages/clients/dish/src/plugins/Header/locales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Locale } from '@polar/lib-custom-types'

export const dishHeaderDe = {
header: {
text: 'Denkmalkarte Schleswig-Holstein',
},
} as const

const locales: Locale[] = [
{
type: 'de',
resources: {
plugins: {
dish: {
...dishHeaderDe,
},
},
},
},
{
type: 'en',
resources: {
plugins: {
dish: {
header: {},
},
},
},
},
]

export default locales
Loading