Skip to content

Commit

Permalink
add ts support for i18n strings
Browse files Browse the repository at this point in the history
Resolves: #94
  • Loading branch information
warm-coolguy committed Jan 16, 2025
1 parent efc36ba commit 6830c9d
Show file tree
Hide file tree
Showing 114 changed files with 1,054 additions and 1,043 deletions.
58 changes: 58 additions & 0 deletions @types/i18next.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'i18next'

import { common as resourcesDeCore } from '../packages/core/src/language/locales/de'
import { resourcesDe as resourcesDeAddressSearch } from '../packages/plugins/AddressSearch/src/language'
import { resourcesDe as resourcesDeAttributions } from '../packages/plugins/Attributions/src/language'
import { resourcesDe as resourcesDeDraw } from '../packages/plugins/Draw/src/language'
import { resourcesDe as resourcesDeExport } from '../packages/plugins/Export/src/language'
import { resourcesDe as resourcesDeFilter } from '../packages/plugins/Filter/src/language'
import { resourcesDe as resourcesDeFullscreen } from '../packages/plugins/Fullscreen/src/language'
import { resourcesDe as resourcesDeGeoLocation } from '../packages/plugins/GeoLocation/src/language'
import { resourcesDe as resourcesDeGfi } from '../packages/plugins/Gfi/src/language'
import { resourcesDe as resourcesDeIconMenu } from '../packages/plugins/IconMenu/src/language'
import { resourcesDe as resourcesDeLayerChooser } from '../packages/plugins/LayerChooser/src/language'
import { resourcesDe as resourcesDeLegend } from '../packages/plugins/Legend/src/language'
import { resourcesDe as resourcesDeLoadingIndicator } from '../packages/plugins/LoadingIndicator/src/language'
import { resourcesDe as resourcesDePins } from '../packages/plugins/Pins/src/language'
import { resourcesDe as resourcesDeScale } from '../packages/plugins/Scale/src/language'
import { resourcesDe as resourcesDeToast } from '../packages/plugins/Toast/src/language'
import { resourcesDe as resourcesDeZoom } from '../packages/plugins/Zoom/src/language'
import { dishDe } from '../packages/clients/dish/src/language'
import { meldemichelDe } from '../packages/clients/meldemichel/src/language'
import { snowboxDe } from '../packages/clients/snowbox/src/language'
import { textLocatorDe } from '../packages/clients/textLocator/src/language'

const resources = {
common: {
...resourcesDeCore,
dish: dishDe,
meldemichel: meldemichelDe,
snowbox: snowboxDe,
textLocator: textLocatorDe,
plugins: {
addressSearch: resourcesDeAddressSearch.plugins.addressSearch,
attributions: resourcesDeAttributions.plugins.attributions,
draw: resourcesDeDraw.plugins.draw,
export: resourcesDeExport.plugins.export,
filter: resourcesDeFilter.plugins.filter,
fullscreen: resourcesDeFullscreen.plugins.fullscreen,
geoLocation: resourcesDeGeoLocation.plugins.geoLocation,
gfi: resourcesDeGfi.plugins.gfi,
iconMenu: resourcesDeIconMenu.plugins.iconMenu,
layerChooser: resourcesDeLayerChooser.plugins.layerChooser,
legend: resourcesDeLegend.plugins.legend,
loadingIndicator: resourcesDeLoadingIndicator.plugins.loadingIndicator,
pins: resourcesDePins.plugins.pins,
scale: resourcesDeScale.plugins.scale,
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.

52 changes: 52 additions & 0 deletions packages/clients/dish/src/language.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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 = [
{
type: 'de',
resources: resourcesDe,
},
{
type: 'en',
resources: resourcesEn,
},
]

export default locales
47 changes: 0 additions & 47 deletions packages/clients/dish/src/locales.ts

This file was deleted.

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 './locales'
import locales from './language'

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
20 changes: 10 additions & 10 deletions packages/clients/dish/src/plugins/Modal/Welcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@
<img
class="landesdachmarke"
src="./landesdachmarke_denkmalpflege.jpg"
:alt="$t('common:plugins.dish.modal.landesdachmarkeAlt')"
:alt="$t('plugins.dish.modal.landesdachmarkeAlt')"
/>
<v-card-title class="modal-title" tag="h1">
{{ $t('common:plugins.dish.modal.welcome.header') }}
{{ $t('plugins.dish.modal.welcome.header') }}
</v-card-title>
<v-card-text>
{{ $t('common:plugins.dish.modal.welcome.p1') }}
{{ $t('plugins.dish.modal.welcome.p1') }}
</v-card-text>
<v-card-text>
{{ $t('common:plugins.dish.modal.welcome.p2') }}
{{ $t('plugins.dish.modal.welcome.p2') }}
</v-card-text>
<v-card-text>
{{ $t('common:plugins.dish.modal.welcome.p3') }}
{{ $t('plugins.dish.modal.welcome.p3') }}
<a
class="modal-link"
href="https://www.schleswig-holstein.de/DE/landesregierung/ministerien-behoerden/LD/Kontakt/kontakt_node.html"
target="_blank"
>
<v-icon x-small color="#0089ca">fa-chevron-right</v-icon>
{{ $t('common:plugins.dish.modal.welcome.link1') }}.
{{ $t('plugins.dish.modal.welcome.link1') }}.
</a>
</v-card-text>
<v-card-text>
{{ $t('common:plugins.dish.modal.welcome.p4') }}
{{ $t('plugins.dish.modal.welcome.p4') }}
<a
class="modal-link"
href="https://www.schleswig-holstein.de/DE/landesregierung/ministerien-behoerden/LD/Organisation/organisation_node.html"
target="_blank"
>
<v-icon x-small color="#0089ca">fa-chevron-right</v-icon>
{{ $t('common:plugins.dish.modal.welcome.link2') }}.
{{ $t('plugins.dish.modal.welcome.link2') }}.
</a>
</v-card-text>
<v-card-actions class="modal-actions">
<v-checkbox
v-model="confirmed"
color="#003064"
:label="$t('common:plugins.dish.modal.welcome.confirmRead')"
:label="$t('plugins.dish.modal.welcome.confirmRead')"
></v-checkbox>
<v-btn
class="text-none primaryContrast--text closeButton"
color="primary"
:disabled="!confirmed"
@click="closed = true"
>
{{ $t('common:plugins.dish.modal.welcome.closeInfo') }}
{{ $t('plugins.dish.modal.welcome.closeInfo') }}
</v-btn>
</v-card-actions>
</v-card>
Expand Down
2 changes: 1 addition & 1 deletion packages/clients/dish/src/utils/navigateToDenkmal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function navigateToDenkmal(instance, objektId: string) {
console.error('@polar/client-dish', error)
instance.$store.dispatch('plugin/toast/addToast', {
type: 'warning',
text: 'common:dish.idNotFound',
text: 'dish.idNotFound',
})
})
}
4 changes: 2 additions & 2 deletions packages/clients/dish/src/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ export function search(
if (error.message === dishBackendSizeError) {
this.dispatch('plugin/toast/addToast', {
type: 'warning',
text: 'common:dish.backendSizeError',
text: 'dish.backendSizeError',
})
} else {
this.dispatch('plugin/toast/addToast', {
type: 'error',
text: 'common:dish.unknownError',
text: 'dish.unknownError',
})
}
}
Expand Down
3 changes: 0 additions & 3 deletions packages/clients/dish/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/clients/generic/tsconfig.json

This file was deleted.

Loading

0 comments on commit 6830c9d

Please sign in to comment.