From 8b3dfaf075d3d346e4d44b23e3be5fb24832b35b Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 09:10:17 +0100 Subject: [PATCH 01/12] Add page title to the localization. --- presenter/src/locales/de.json | 14 ++++++++++---- presenter/src/locales/en.json | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/presenter/src/locales/de.json b/presenter/src/locales/de.json index 61a37d02b9..c44cfb616b 100644 --- a/presenter/src/locales/de.json +++ b/presenter/src/locales/de.json @@ -1,7 +1,8 @@ { "about": {}, "auth": { - "content": "Logge ein..." + "content": "Logge ein...", + "title": "DreamMall {'|'} Authentifizierung" }, "dataProtection": { "euDispute": { @@ -26,9 +27,11 @@ "revocation": { "content": "Nur mit Ihrer ausdrücklichen Einwilligung sind einige Vorgänge der Datenverarbeitung möglich. Ein Widerruf Ihrer bereits erteilten Einwilligung ist jederzeit möglich. Für den Widerruf genügt eine formlose Mitteilung per E-Mail. Die Rechtmäßigkeit der bis zum Widerruf erfolgten Datenverarbeitung bleibt vom Widerruf unberührt.", "headline": "Widerruf Ihrer Einwilligung zur Datenverarbeitung" - } + }, + "title": "DreamMall {'|'} Datenschutz" }, "error": { + "title": "DreamMall {'|'} Fehler", "404": { "h1": "404 Seite nicht gefunden", "text": "Diese Seite konnte nicht gefunden werden." @@ -161,7 +164,8 @@ "content": "Umsatzsteuer-Identifikationsnummer gemäß § 27 a Umsatzsteuergesetz:", "headline": "Umsatzsteuer-ID", "id": "DE356946303" - } + }, + "title": "DreamMall {'|'} Impressum" }, "menu": { "eMail": "E-Mail", @@ -209,8 +213,10 @@ }, "success": { "text": "Sie haben Ihr Newsletterabbonoment erfolgreich bestätigt. Sie werden in Kürze auf die Startseite weitergeleitet." - } + }, + "title":"DreamMall {'|'} Newsletter" }, + "title": "DreamMall", "validation": { "fieldNoEmail": "Dieses Feld muss eine Email-Adresse sein.", "fieldRequired": "Dieses Feld wird benötigt.", diff --git a/presenter/src/locales/en.json b/presenter/src/locales/en.json index 540dfc3f50..ad1b9a0aba 100644 --- a/presenter/src/locales/en.json +++ b/presenter/src/locales/en.json @@ -1,7 +1,8 @@ { "about": {}, "auth": { - "content": "Logging in..." + "content": "Logging in...", + "title": "DreamMall {'|'} Authentication" }, "dataProtection": { "euDispute": { @@ -26,9 +27,11 @@ "revocation": { "content": "Some data processing operations are only possible with your express consent. You can withdraw your consent at any time. An informal notification by e-mail is sufficient for the revocation. The legality of the data processing carried out until the revocation remains unaffected by the revocation.", "headline": "Withdrawal of your consent to data processing" - } + }, + "title": "DreamMall {'|'} Privacy Policy" }, "error": { + "title": "DreamMall {'|'} Error", "404": { "h1": "404 Page not found", "text": "This page could not be found." @@ -161,7 +164,8 @@ "content": "Sales tax identification number according to § 27 a sales tax law:", "headline": "Sales tax ID", "id": "DE356946303" - } + }, + "title": "DreamMall {'|'} Imprint" }, "menu": { "eMail": "E-Mail", @@ -209,8 +213,10 @@ }, "success": { "text": "You have successfully confirmed your newsletter subscription. You will be redirected to the start page shortly." - } + }, + "title":"DreamMall {'|'} Newsletter" }, + "title": "DreamMall", "validation": { "fieldNoEmail": "This field must be an email address", "fieldRequired": "This field is required", From 28309305117b63f35912771905088f3a55eb882c Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 09:11:06 +0100 Subject: [PATCH 02/12] Change the translation in +title.ts page to use i18n. --- presenter/src/pages/_error/+title.ts | 6 +++++- presenter/src/pages/datenschutz/+title.ts | 6 +++++- presenter/src/pages/impressum/+title.ts | 7 ++++++- presenter/src/pages/index/+title.ts | 6 ++++-- presenter/src/pages/optin/+title.ts | 7 ++++++- presenter/src/pages/silent-refresh/+title.ts | 6 +++++- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/presenter/src/pages/_error/+title.ts b/presenter/src/pages/_error/+title.ts index 17faffcf02..574b5b13f7 100644 --- a/presenter/src/pages/_error/+title.ts +++ b/presenter/src/pages/_error/+title.ts @@ -1 +1,5 @@ -export const title = 'DreamMall | Fehler' +import i18n from '#plugins/i18n' + +export const title = () => { + return i18n.global.t('error.title') +} diff --git a/presenter/src/pages/datenschutz/+title.ts b/presenter/src/pages/datenschutz/+title.ts index fe2528e1bb..66b042c884 100644 --- a/presenter/src/pages/datenschutz/+title.ts +++ b/presenter/src/pages/datenschutz/+title.ts @@ -1 +1,5 @@ -export const title = 'DreamMall | Datenschutz' +import i18n from '#plugins/i18n' + +export const title = () => { + return i18n.global.t('dataProtection.title') +} diff --git a/presenter/src/pages/impressum/+title.ts b/presenter/src/pages/impressum/+title.ts index 72f7a6bc1e..8c37d1d1da 100644 --- a/presenter/src/pages/impressum/+title.ts +++ b/presenter/src/pages/impressum/+title.ts @@ -1 +1,6 @@ -export const title = 'DreamMall | Impressum' +import i18n from '#plugins/i18n' + +// DreamMall | Impressum +export const title = () => { + return i18n.global.t('impress.title') +} diff --git a/presenter/src/pages/index/+title.ts b/presenter/src/pages/index/+title.ts index 125d4b660c..d7555eb3d9 100644 --- a/presenter/src/pages/index/+title.ts +++ b/presenter/src/pages/index/+title.ts @@ -1,3 +1,5 @@ -import { META } from '#src/env' +import i18n from '#plugins/i18n' -export const title = META.DEFAULT_TITLE +export const title = () => { + return i18n.global.t('title') +} diff --git a/presenter/src/pages/optin/+title.ts b/presenter/src/pages/optin/+title.ts index 0260dfd2c5..9cd8c93054 100644 --- a/presenter/src/pages/optin/+title.ts +++ b/presenter/src/pages/optin/+title.ts @@ -1 +1,6 @@ -export const title = 'DreamMall | Newsletter' +import i18n from '#plugins/i18n' + +// 'DreamMall | Newsletter' +export const title = () => { + return i18n.global.t('optin.title') +} diff --git a/presenter/src/pages/silent-refresh/+title.ts b/presenter/src/pages/silent-refresh/+title.ts index 111df23145..3d4d484ec0 100644 --- a/presenter/src/pages/silent-refresh/+title.ts +++ b/presenter/src/pages/silent-refresh/+title.ts @@ -1 +1,5 @@ -export const title = 'DreamMall | Authentifizierung' +import i18n from '#plugins/i18n' + +export const title = () => { + return i18n.global.t('auth.title') // 'DreamMall | Authentifizierung' +} From b25525a7fc4568cc7a427555ea51a6489ac5ec86 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 09:43:43 +0100 Subject: [PATCH 03/12] Add translation of auth page title. --- presenter/src/pages/auth/+title.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/presenter/src/pages/auth/+title.ts b/presenter/src/pages/auth/+title.ts index 111df23145..3d4d484ec0 100644 --- a/presenter/src/pages/auth/+title.ts +++ b/presenter/src/pages/auth/+title.ts @@ -1 +1,5 @@ -export const title = 'DreamMall | Authentifizierung' +import i18n from '#plugins/i18n' + +export const title = () => { + return i18n.global.t('auth.title') // 'DreamMall | Authentifizierung' +} From 17c02a4d10407684e33eb1fa22adf568919cb1df Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 09:44:08 +0100 Subject: [PATCH 04/12] Change test of title since it is now a function. --- presenter/src/pages/_error/Page.test.ts | 4 +++- presenter/src/pages/auth/Page.test.ts | 3 ++- presenter/src/pages/datenschutz/Page.test.ts | 4 +++- presenter/src/pages/impressum/Page.test.ts | 4 +++- presenter/src/pages/index/Page.test.ts | 4 +++- presenter/src/pages/optin/Page.test.ts | 3 ++- presenter/src/pages/silent-refresh/Page.test.ts | 3 ++- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/presenter/src/pages/_error/Page.test.ts b/presenter/src/pages/_error/Page.test.ts index a7c4bca7d9..ebca31c190 100644 --- a/presenter/src/pages/_error/Page.test.ts +++ b/presenter/src/pages/_error/Page.test.ts @@ -3,12 +3,14 @@ import { describe, it, expect, beforeEach } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' + import ErrorPage from './+Page.vue' import { title } from './+title' describe('ErrorPage', () => { it('title returns correct title', () => { - expect(title).toBe('DreamMall | Fehler') + expect(title()).toBe(i18n.global.t('error.title')) }) describe('500 Error', () => { const WrapperUndefined = () => { diff --git a/presenter/src/pages/auth/Page.test.ts b/presenter/src/pages/auth/Page.test.ts index 7a5aa8b59f..15602566cf 100644 --- a/presenter/src/pages/auth/Page.test.ts +++ b/presenter/src/pages/auth/Page.test.ts @@ -4,6 +4,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' import { useAuthStore } from '#stores/authStore' import { authService } from '#tests/mock.authService' @@ -51,7 +52,7 @@ describe('AuthPage', () => { }) it('title returns correct title', () => { - expect(title).toBe('DreamMall | Authentifizierung') + expect(title()).toBe(i18n.global.t('auth.title')) }) it('renders', () => { diff --git a/presenter/src/pages/datenschutz/Page.test.ts b/presenter/src/pages/datenschutz/Page.test.ts index 70f3ba834c..4df8247ca8 100644 --- a/presenter/src/pages/datenschutz/Page.test.ts +++ b/presenter/src/pages/datenschutz/Page.test.ts @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' + import DataPrivacyPage from './+Page.vue' import { title } from './+title' @@ -14,7 +16,7 @@ describe('DataPrivacyPage', () => { }) it('title returns correct title', () => { - expect(title).toBe('DreamMall | Datenschutz') + expect(title()).toBe(i18n.global.t('dataProtection.title')) }) it('renders', () => { diff --git a/presenter/src/pages/impressum/Page.test.ts b/presenter/src/pages/impressum/Page.test.ts index cb61152e6c..01f56c3e61 100644 --- a/presenter/src/pages/impressum/Page.test.ts +++ b/presenter/src/pages/impressum/Page.test.ts @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' + import ImpressumPage from './+Page.vue' import { title } from './+title' @@ -14,7 +16,7 @@ describe('ImpressumPage', () => { }) it('title returns correct title', () => { - expect(title).toBe('DreamMall | Impressum') + expect(title()).toBe(i18n.global.t('impress.title')) }) it('renders', () => { diff --git a/presenter/src/pages/index/Page.test.ts b/presenter/src/pages/index/Page.test.ts index 026c20fd22..73541580eb 100644 --- a/presenter/src/pages/index/Page.test.ts +++ b/presenter/src/pages/index/Page.test.ts @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' + import IndexPage from './+Page.vue' import { title } from './+title' @@ -14,7 +16,7 @@ describe('IndexPage', () => { }) it('title returns default title', () => { - expect(title).toBe('DreamMall') + expect(title()).toBe(i18n.global.t('title')) }) it('renders', () => { diff --git a/presenter/src/pages/optin/Page.test.ts b/presenter/src/pages/optin/Page.test.ts index d6e131ebc5..97159ceffd 100644 --- a/presenter/src/pages/optin/Page.test.ts +++ b/presenter/src/pages/optin/Page.test.ts @@ -5,6 +5,7 @@ import { Component, h } from 'vue' import { VApp } from 'vuetify/components' import { confirmNewsletter } from '#mutations/confirmNewsletter' +import i18n from '#plugins/i18n' import { mockClient } from '#tests/mock.apolloClient' import OptinPage from './+Page.vue' @@ -45,7 +46,7 @@ describe('OptinPage', () => { }) it('title returns correct title', () => { - expect(title).toBe('DreamMall | Newsletter') + expect(title()).toBe(i18n.global.t('optin.title')) }) it('route returns `/optin/@code', () => { diff --git a/presenter/src/pages/silent-refresh/Page.test.ts b/presenter/src/pages/silent-refresh/Page.test.ts index 57ce86a8c2..f8e57d06c0 100644 --- a/presenter/src/pages/silent-refresh/Page.test.ts +++ b/presenter/src/pages/silent-refresh/Page.test.ts @@ -4,6 +4,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' import { Component, h } from 'vue' import { VApp } from 'vuetify/components' +import i18n from '#plugins/i18n' import { authService } from '#tests/mock.authService' import SilentRefreshPage from './+Page.vue' @@ -31,7 +32,7 @@ describe('SilentRefreshPage', () => { }) it('title returns correct title', () => { - expect(title).toBe('DreamMall | Authentifizierung') + expect(title()).toBe(i18n.global.t('auth.title')) }) it('renders', () => { From 5246182fd4670877f4786b4ec2e6157ef9425387 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 09:52:14 +0100 Subject: [PATCH 05/12] Sort locales. --- presenter/src/locales/de.json | 6 +++--- presenter/src/locales/en.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/presenter/src/locales/de.json b/presenter/src/locales/de.json index c44cfb616b..53baeecfe6 100644 --- a/presenter/src/locales/de.json +++ b/presenter/src/locales/de.json @@ -31,7 +31,6 @@ "title": "DreamMall {'|'} Datenschutz" }, "error": { - "title": "DreamMall {'|'} Fehler", "404": { "h1": "404 Seite nicht gefunden", "text": "Diese Seite konnte nicht gefunden werden." @@ -39,7 +38,8 @@ "500": { "h1": "500 Interner Fehler", "text": "Etwas ist schief gegangen." - } + }, + "title": "DreamMall {'|'} Fehler" }, "home": { "aboutSection": { @@ -214,7 +214,7 @@ "success": { "text": "Sie haben Ihr Newsletterabbonoment erfolgreich bestätigt. Sie werden in Kürze auf die Startseite weitergeleitet." }, - "title":"DreamMall {'|'} Newsletter" + "title": "DreamMall {'|'} Newsletter" }, "title": "DreamMall", "validation": { diff --git a/presenter/src/locales/en.json b/presenter/src/locales/en.json index ad1b9a0aba..4181e9fcb9 100644 --- a/presenter/src/locales/en.json +++ b/presenter/src/locales/en.json @@ -31,7 +31,6 @@ "title": "DreamMall {'|'} Privacy Policy" }, "error": { - "title": "DreamMall {'|'} Error", "404": { "h1": "404 Page not found", "text": "This page could not be found." @@ -39,7 +38,8 @@ "500": { "h1": "500 Internal error", "text": "Something went wrong." - } + }, + "title": "DreamMall {'|'} Error" }, "home": { "aboutSection": { @@ -214,7 +214,7 @@ "success": { "text": "You have successfully confirmed your newsletter subscription. You will be redirected to the start page shortly." }, - "title":"DreamMall {'|'} Newsletter" + "title": "DreamMall {'|'} Newsletter" }, "title": "DreamMall", "validation": { From c12d5a7dfc5d067bab4a5f5725fd6d3dd391cfa2 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 10:01:55 +0100 Subject: [PATCH 06/12] Change default title to i18n.global.t('title') --- presenter/.env.dist | 1 - presenter/renderer/utils.ts | 3 ++- presenter/src/env.test.ts | 1 - presenter/src/env.ts | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/presenter/.env.dist b/presenter/.env.dist index c70cbf337a..43fb1f185c 100644 --- a/presenter/.env.dist +++ b/presenter/.env.dist @@ -17,4 +17,3 @@ PUBLIC_ENV__ENDPOINTS__GRAPHQL_URI=http://localhost:4000/ PUBLIC_ENV__META__BASE_URL="http://localhost:3000" PUBLIC_ENV__META__DEFAULT_AUTHOR="DreamMall Verlag GbR" PUBLIC_ENV__META__DEFAULT_DESCRIPTION="Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben" -PUBLIC_ENV__META__DEFAULT_TITLE="DreamMall" diff --git a/presenter/renderer/utils.ts b/presenter/renderer/utils.ts index 72833d5e31..2c0297ba51 100644 --- a/presenter/renderer/utils.ts +++ b/presenter/renderer/utils.ts @@ -1,5 +1,6 @@ import { PageContext } from 'vike/types' +import i18n from '#plugins/i18n' import { META } from '#src/env' function getTitle(pageContext: PageContext) { @@ -7,7 +8,7 @@ function getTitle(pageContext: PageContext) { const val = pageContext.config.title if (typeof val === 'string') return val if (typeof val === 'function') return String(val(pageContext)) - return META.DEFAULT_TITLE + return i18n.global.t('title') } function getDescription(pageContext: PageContext) { const val = pageContext.config.description diff --git a/presenter/src/env.test.ts b/presenter/src/env.test.ts index 8d5ccadf7f..f681c3832b 100644 --- a/presenter/src/env.test.ts +++ b/presenter/src/env.test.ts @@ -9,7 +9,6 @@ describe('env', () => { DEFAULT_AUTHOR: 'DreamMall Verlag GbR', DEFAULT_DESCRIPTION: 'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben', - DEFAULT_TITLE: 'DreamMall', }) }) }) diff --git a/presenter/src/env.ts b/presenter/src/env.ts index 52124b7ead..7a0d9f3257 100644 --- a/presenter/src/env.ts +++ b/presenter/src/env.ts @@ -24,7 +24,6 @@ const META = { 'DreamMall Verlag GbR') as string, DEFAULT_DESCRIPTION: (import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION ?? 'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben') as string, - DEFAULT_TITLE: (import.meta.env.PUBLIC_ENV__META__DEFAULT_TITLE ?? 'DreamMall') as string, } export { AUTH, ENDPOINTS, META } From 0e5993e4dd2c0b6b204e2f657b4184ff9fb08061 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 11:32:21 +0100 Subject: [PATCH 07/12] Shorten needs no {} --- presenter/src/pages/_error/+title.ts | 4 +--- presenter/src/pages/auth/+title.ts | 4 +--- presenter/src/pages/datenschutz/+title.ts | 4 +--- presenter/src/pages/impressum/+title.ts | 5 +---- presenter/src/pages/index/+title.ts | 4 +--- presenter/src/pages/optin/+title.ts | 4 +--- presenter/src/pages/silent-refresh/+title.ts | 4 +--- 7 files changed, 7 insertions(+), 22 deletions(-) diff --git a/presenter/src/pages/_error/+title.ts b/presenter/src/pages/_error/+title.ts index 574b5b13f7..f81d3f43a5 100644 --- a/presenter/src/pages/_error/+title.ts +++ b/presenter/src/pages/_error/+title.ts @@ -1,5 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => { - return i18n.global.t('error.title') -} +export const title = () => i18n.global.t('error.title') diff --git a/presenter/src/pages/auth/+title.ts b/presenter/src/pages/auth/+title.ts index 3d4d484ec0..9a5438414c 100644 --- a/presenter/src/pages/auth/+title.ts +++ b/presenter/src/pages/auth/+title.ts @@ -1,5 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => { - return i18n.global.t('auth.title') // 'DreamMall | Authentifizierung' -} +export const title = () => i18n.global.t('auth.title') diff --git a/presenter/src/pages/datenschutz/+title.ts b/presenter/src/pages/datenschutz/+title.ts index 66b042c884..6940a7f21d 100644 --- a/presenter/src/pages/datenschutz/+title.ts +++ b/presenter/src/pages/datenschutz/+title.ts @@ -1,5 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => { - return i18n.global.t('dataProtection.title') -} +export const title = () => i18n.global.t('dataProtection.title') diff --git a/presenter/src/pages/impressum/+title.ts b/presenter/src/pages/impressum/+title.ts index 8c37d1d1da..dd3a776b22 100644 --- a/presenter/src/pages/impressum/+title.ts +++ b/presenter/src/pages/impressum/+title.ts @@ -1,6 +1,3 @@ import i18n from '#plugins/i18n' -// DreamMall | Impressum -export const title = () => { - return i18n.global.t('impress.title') -} +export const title = () => i18n.global.t('impress.title') diff --git a/presenter/src/pages/index/+title.ts b/presenter/src/pages/index/+title.ts index d7555eb3d9..d6cec9937c 100644 --- a/presenter/src/pages/index/+title.ts +++ b/presenter/src/pages/index/+title.ts @@ -1,5 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => { - return i18n.global.t('title') -} +export const title = () => i18n.global.t('title') diff --git a/presenter/src/pages/optin/+title.ts b/presenter/src/pages/optin/+title.ts index 9cd8c93054..390b93794e 100644 --- a/presenter/src/pages/optin/+title.ts +++ b/presenter/src/pages/optin/+title.ts @@ -1,6 +1,4 @@ import i18n from '#plugins/i18n' // 'DreamMall | Newsletter' -export const title = () => { - return i18n.global.t('optin.title') -} +export const title = () => i18n.global.t('optin.title') diff --git a/presenter/src/pages/silent-refresh/+title.ts b/presenter/src/pages/silent-refresh/+title.ts index 3d4d484ec0..9a5438414c 100644 --- a/presenter/src/pages/silent-refresh/+title.ts +++ b/presenter/src/pages/silent-refresh/+title.ts @@ -1,5 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => { - return i18n.global.t('auth.title') // 'DreamMall | Authentifizierung' -} +export const title = () => i18n.global.t('auth.title') From 64751e7ded253e9ee30ff5b3e56a63879216dd49 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 11:32:59 +0100 Subject: [PATCH 08/12] Better test definition. --- presenter/src/components/language/LanguageSelector.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/presenter/src/components/language/LanguageSelector.test.ts b/presenter/src/components/language/LanguageSelector.test.ts index 1f84e67cc1..788865856f 100644 --- a/presenter/src/components/language/LanguageSelector.test.ts +++ b/presenter/src/components/language/LanguageSelector.test.ts @@ -23,12 +23,12 @@ describe('LanguageSelector', () => { expect(wrapper.element).toMatchSnapshot() }) - describe('switch locale with existing locale', () => { + describe('switch locale', () => { beforeEach(async () => { await vSelect.setValue('en') }) - it('change locale', () => { + it('to en', () => { expect(i18n.global.locale.value).toBe('en') }) }) From 436d5c70dbe3831b8bb9d3cbd3c193451a2511a6 Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 11:47:24 +0100 Subject: [PATCH 09/12] Change default title from title to meta.defaultTitle & add meta.defaultDescription. --- presenter/src/locales/de.json | 5 ++++- presenter/src/locales/en.json | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/presenter/src/locales/de.json b/presenter/src/locales/de.json index 53baeecfe6..9fd1923ef2 100644 --- a/presenter/src/locales/de.json +++ b/presenter/src/locales/de.json @@ -206,6 +206,10 @@ "sitemap": "Sitemap" } }, + "meta": { + "defaultDescription": "Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben", + "defaultTitle": "DreamMall" + }, "optin": { "error": { "link": "Erneut eintragen", @@ -216,7 +220,6 @@ }, "title": "DreamMall {'|'} Newsletter" }, - "title": "DreamMall", "validation": { "fieldNoEmail": "Dieses Feld muss eine Email-Adresse sein.", "fieldRequired": "Dieses Feld wird benötigt.", diff --git a/presenter/src/locales/en.json b/presenter/src/locales/en.json index 4181e9fcb9..a1b2baf90f 100644 --- a/presenter/src/locales/en.json +++ b/presenter/src/locales/en.json @@ -206,6 +206,10 @@ "sitemap": "Sitemap" } }, + "meta": { + "defaultDescription": "Expanding your reach Exploiting all possibilities together Quality of life", + "defaultTitle": "DreamMall" + }, "optin": { "error": { "link": "Register again", @@ -216,7 +220,6 @@ }, "title": "DreamMall {'|'} Newsletter" }, - "title": "DreamMall", "validation": { "fieldNoEmail": "This field must be an email address", "fieldRequired": "This field is required", From 273f033d638a293a3d45fcaa75cca0a4ba9bebdb Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 11:48:00 +0100 Subject: [PATCH 10/12] Remove DEFAULT_DESCRIPTION from env and set it to locales. --- presenter/.env.dist | 1 - presenter/renderer/utils.ts | 5 ++--- presenter/src/env.test.ts | 2 -- presenter/src/env.ts | 2 -- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/presenter/.env.dist b/presenter/.env.dist index 43fb1f185c..155d848885 100644 --- a/presenter/.env.dist +++ b/presenter/.env.dist @@ -16,4 +16,3 @@ PUBLIC_ENV__ENDPOINTS__GRAPHQL_URI=http://localhost:4000/ # META PUBLIC_ENV__META__BASE_URL="http://localhost:3000" PUBLIC_ENV__META__DEFAULT_AUTHOR="DreamMall Verlag GbR" -PUBLIC_ENV__META__DEFAULT_DESCRIPTION="Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben" diff --git a/presenter/renderer/utils.ts b/presenter/renderer/utils.ts index 2c0297ba51..b42bb38f76 100644 --- a/presenter/renderer/utils.ts +++ b/presenter/renderer/utils.ts @@ -1,20 +1,19 @@ import { PageContext } from 'vike/types' import i18n from '#plugins/i18n' -import { META } from '#src/env' function getTitle(pageContext: PageContext) { // The value exported by /pages/**/+title.js is available at pageContext.config.title const val = pageContext.config.title if (typeof val === 'string') return val if (typeof val === 'function') return String(val(pageContext)) - return i18n.global.t('title') + return i18n.global.t('meta.defaultTitle') } function getDescription(pageContext: PageContext) { const val = pageContext.config.description if (typeof val === 'string') return val if (typeof val === 'function') return val(pageContext) - return META.DEFAULT_DESCRIPTION + return i18n.global.t('meta.defaultDescription') } export { getTitle, getDescription } diff --git a/presenter/src/env.test.ts b/presenter/src/env.test.ts index f681c3832b..986905b1a4 100644 --- a/presenter/src/env.test.ts +++ b/presenter/src/env.test.ts @@ -7,8 +7,6 @@ describe('env', () => { expect(META).toEqual({ BASE_URL: 'http://localhost:3000', DEFAULT_AUTHOR: 'DreamMall Verlag GbR', - DEFAULT_DESCRIPTION: - 'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben', }) }) }) diff --git a/presenter/src/env.ts b/presenter/src/env.ts index 7a0d9f3257..7903da73ef 100644 --- a/presenter/src/env.ts +++ b/presenter/src/env.ts @@ -22,8 +22,6 @@ const META = { BASE_URL: (import.meta.env.PUBLIC_ENV__META__BASE_URL ?? 'http://localhost:3000') as string, DEFAULT_AUTHOR: (import.meta.env.PUBLIC_ENV__META__DEFAULT_AUTHOR ?? 'DreamMall Verlag GbR') as string, - DEFAULT_DESCRIPTION: (import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION ?? - 'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben') as string, } export { AUTH, ENDPOINTS, META } From 76961e9d645fda21b4ee526321dd0d63184e7e3c Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 11:51:51 +0100 Subject: [PATCH 11/12] Change title of index page to meta.defaultTitle. --- presenter/src/pages/index/+title.ts | 2 +- presenter/src/pages/index/Page.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/presenter/src/pages/index/+title.ts b/presenter/src/pages/index/+title.ts index d6cec9937c..b2c347d335 100644 --- a/presenter/src/pages/index/+title.ts +++ b/presenter/src/pages/index/+title.ts @@ -1,3 +1,3 @@ import i18n from '#plugins/i18n' -export const title = () => i18n.global.t('title') +export const title = () => i18n.global.t('meta.defaultTitle') diff --git a/presenter/src/pages/index/Page.test.ts b/presenter/src/pages/index/Page.test.ts index 73541580eb..609153de51 100644 --- a/presenter/src/pages/index/Page.test.ts +++ b/presenter/src/pages/index/Page.test.ts @@ -16,7 +16,7 @@ describe('IndexPage', () => { }) it('title returns default title', () => { - expect(title()).toBe(i18n.global.t('title')) + expect(title()).toBe(i18n.global.t('meta.defaultTitle')) }) it('renders', () => { From 344888664b3eda2d451fa594c17cab5613ebf2be Mon Sep 17 00:00:00 2001 From: elweyn Date: Tue, 26 Mar 2024 13:59:41 +0100 Subject: [PATCH 12/12] Better translation of defaultDescription. --- presenter/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presenter/src/locales/en.json b/presenter/src/locales/en.json index a1b2baf90f..52f218f057 100644 --- a/presenter/src/locales/en.json +++ b/presenter/src/locales/en.json @@ -207,7 +207,7 @@ } }, "meta": { - "defaultDescription": "Expanding your reach Exploiting all possibilities together Quality of life", + "defaultDescription": "Expanding your reach making the most of opportunities enhance quality of life together", "defaultTitle": "DreamMall" }, "optin": {