Skip to content

Commit

Permalink
Merge branch 'master' into 208-feat-page-title-translate
Browse files Browse the repository at this point in the history
  • Loading branch information
Elweyn authored Mar 26, 2024
2 parents 76961e9 + d89cb76 commit 97c003c
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 21 deletions.
2 changes: 0 additions & 2 deletions presenter/locales/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions presenter/locales/locales.ts

This file was deleted.

2 changes: 1 addition & 1 deletion presenter/renderer/+onBeforeRoute.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContext } from 'vike/types'

import { extractLocale } from '#root/locales/extractLocale'
import { extractLocale } from '#src/locales'

export function onBeforeRoute(pageContext: PageContext) {
const { urlWithoutLocale, locale } = extractLocale(pageContext.urlPathname)
Expand Down
6 changes: 2 additions & 4 deletions presenter/renderer/+onPrerenderStart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PageContextServer } from 'vike/types'

import { locales, localeDefault } from '#root/locales'
import { locales } from '#src/locales'

export { onPrerenderStart }

Expand All @@ -15,9 +15,7 @@ function onPrerenderStart(prerenderContext: { pageContexts: PageContextServer[]
locales.forEach((locale) => {
// Localize URL
let { urlOriginal } = pageContext
if (locale !== localeDefault) {
urlOriginal = `/${locale}${urlOriginal}`
}
urlOriginal = `/${locale}${urlOriginal}`
storePageContexts.push({
...pageContext,
urlOriginal,
Expand Down
2 changes: 1 addition & 1 deletion presenter/renderer/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createApolloClient } from '#plugins/apollo'
import i18n from '#plugins/i18n'
import pinia from '#plugins/pinia'
import CreateVuetify from '#plugins/vuetify'
import { locales } from '#root/locales'
import { locales } from '#src/locales'
import AuthService from '#src/services/AuthService'
import { useAuthStore } from '#stores/authStore'

Expand Down
5 changes: 3 additions & 2 deletions presenter/renderer/plugins/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { createI18n } from 'vue-i18n'
import { de as vuetifyDe, en as vuetifyEn } from 'vuetify/locale'

import { localeDefault, fallbackLocale } from '#src/locales'
import de from '#src/locales/de.json'
import en from '#src/locales/en.json'

export default createI18n({
legacy: false, // Vuetify does not support the legacy mode of vue-i18n
globalInjection: true,
locale: 'de',
fallbackLocale: 'en',
locale: localeDefault,
fallbackLocale,
messages: {
de: {
$vuetify: vuetifyDe,
Expand Down
2 changes: 1 addition & 1 deletion presenter/src/components/language/LanguageSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { localizedLocale } from '#root/locales'
import { localizedLocale } from '#src/locales'
const languages = ref(localizedLocale)
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { locales, localeDefault, LocaleCode } from './locales'
export type LocaleCode = 'de' | 'en'
export const locales: LocaleCode[] = ['de', 'en']
export const localeDefault = 'de'
export const fallbackLocale = 'en'
export const localizedLocale = [
{ locale: 'de', title: 'Deutsch' },
{ locale: 'en', title: 'English' },
]

export function extractLocale(url: string) {
const urlPaths = url.split('/')
Expand Down
2 changes: 1 addition & 1 deletion presenter/types/PageContext.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocaleCode } from '#root/locales/locales'
import { LocaleCode } from '#src/locales'
import { Page } from '#types/Page'
import { PageProps } from '#types/PageProps'

Expand Down
2 changes: 1 addition & 1 deletion presenter/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config: UserConfig = {
!isStorybook() && vike({ prerender: true }), // SSR only when storybook is not running
vueI18n({
ssr: true,
include: path.resolve(__dirname, './src/locales/**'),
include: path.resolve(__dirname, './src/locales/**.json'),
jitCompilation: false,
}),
checker({
Expand Down

0 comments on commit 97c003c

Please sign in to comment.