Skip to content

Commit

Permalink
added i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
martinapippi authored and wkramer committed Mar 29, 2024
1 parent ca7142a commit b8fc25d
Show file tree
Hide file tree
Showing 10 changed files with 717 additions and 1,153 deletions.
1,817 changes: 666 additions & 1,151 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"typescript-json-serializer": "^6.0.1",
"vue": "^3.4.21",
"vue-i18n": "^9.9.1",
"vue-maplibre-gl": "^3.1.3",
"vue-router": "^4.3.0",
"vue-slider-component": "^4.1.0-beta.7",
"vue": "^3.4.21",
"vuetify": "^3.5.9"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/user-settings/UserSettingsMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<v-divider />
<UserSettingsDialog>
<template #activator="{ props }">
<v-list-item v-bind="props">All Settings ...</v-list-item>
<v-list-item v-bind="props" v-t="'settings.all'"> </v-list-item>
</template>
</UserSettingsDialog>
</v-list>
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"settings": {
"all": "All settings ..."
}
}
18 changes: 18 additions & 0 deletions src/locales/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { en, nl } from 'vuetify/locale'
import enCustom from './en.json'
import nlCustom from './nl.json'

export const messages = {
en: {
$vuetify: {
...en,
},
...enCustom,
},
nl: {
$vuetify: {
...nl,
},
...nlCustom,
},
}
5 changes: 5 additions & 0 deletions src/locales/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"settings": {
"all": "Alle instellingen ..."
}
}
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { defineCustomElements } from '@deltares/fews-ssd-webcomponent/loader'
import 'maplibre-gl/dist/maplibre-gl.css'
import { i18n } from './plugins/i18n'

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
Expand All @@ -19,6 +20,7 @@ app.config.compilerOptions.isCustomElement = (tag) =>
tag === 'schematic-status-display'

app.use(pinia)
app.use(i18n)
app.use(vuetify)

fetch(`${import.meta.env.BASE_URL}app-config.json`)
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createI18n } from 'vue-i18n'
import { messages } from '../locales/index.js'

export const i18n = createI18n<false>({
legacy: false,
locale: import.meta.env.VITE_I18N_LOCALE || 'en',
fallbackLocale: import.meta.env.VITE_I18N_FALLBACK_LOCALE || 'en',
messages,
globalInjection: true,
})
6 changes: 6 additions & 0 deletions src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import '@mdi/font/css/materialdesignicons.css'
import { createVuetify } from 'vuetify'
import * as directives from 'vuetify/directives'
import * as components from 'vuetify/components'
import { createVueI18nAdapter } from 'vuetify/locale/adapters/vue-i18n'
import { i18n } from './i18n'
import { useI18n } from 'vue-i18n'

const vuetify = createVuetify({
components,
directives,
locale: {
adapter: createVueI18nAdapter({ i18n, useI18n }),
},
})

export default vuetify
2 changes: 2 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default defineConfig(({ mode }) => {
__GIT_HASH__: JSON.stringify(commitHash),
__GIT_TAG__: JSON.stringify(commitTag),
__BUILD_DATE__: JSON.stringify(buildDate),
__INTLIFY_JIT_COMPILATION__: JSON.stringify(true), // needed to enable JIT compilation and avoid CSP issues
__INTLIFY_DROP_MESSAGE_COMPILER__: JSON.stringify(true), // needed to enable JIT compilation and avoid CSP issues
},
server: {
headers: {
Expand Down

0 comments on commit b8fc25d

Please sign in to comment.