From 35e9d7f9584a9f8d9c38464697cf6dd60298acb6 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 5 Jan 2023 20:50:25 +0100 Subject: [PATCH] client: fix null i18n interpolation values Fixed the occurence that was reported in along with a similar one. Fixes Also changed the i18n code so this should not happen any more in the general case. --- packages/client/src/i18n.ts | 2 +- packages/client/src/pages/note.vue | 2 +- packages/client/src/scripts/get-note-menu.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/src/i18n.ts b/packages/client/src/i18n.ts index 823900677..49fb1423b 100644 --- a/packages/client/src/i18n.ts +++ b/packages/client/src/i18n.ts @@ -33,7 +33,7 @@ class I18n> { // Perform string interpolation. if (args) { for (const [k, v] of Object.entries(args)) { - str = str.replace(`{${k}}`, v.toString()); + str = str.replace(`{${k}}`, v?.toString()); } } diff --git a/packages/client/src/pages/note.vue b/packages/client/src/pages/note.vue index 412142433..1c351c5c2 100644 --- a/packages/client/src/pages/note.vue +++ b/packages/client/src/pages/note.vue @@ -127,7 +127,7 @@ definePageMetadata(computed(() => note ? { avatar: note.user, path: `/notes/${note.id}`, share: { - title: i18n.t('noteOf', { user: note.user.name }), + title: i18n.t('noteOf', { user: note.user.name || note.user.username }), text: note.text, }, } : null)); diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index d265285a0..57445a49a 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -183,7 +183,7 @@ export function getNoteMenu(props: { function share(): void { navigator.share({ - title: i18n.t('noteOf', { user: appearNote.user.name }), + title: i18n.t('noteOf', { user: appearNote.user.name || appearNote.user.username }), text: appearNote.text, url: `${url}/notes/${appearNote.id}`, });