From b453e2cf1ac4db6fda97055d985ca7c9b31f504c Mon Sep 17 00:00:00 2001 From: Sasha Sorokin <10401817+brawaru@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:21:14 +1100 Subject: [PATCH] Fallback to project type message on unknown types (#1470) This commit adds a fallback to getProjectTypeMessage function to return a generic project type whenever it encounters an unknown project type, ensuring there are no errors when the new project types are added. --- utils/i18n-project-type.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utils/i18n-project-type.ts b/utils/i18n-project-type.ts index 6e3c353ba..840617f83 100644 --- a/utils/i18n-project-type.ts +++ b/utils/i18n-project-type.ts @@ -47,6 +47,14 @@ const projectTypeMessages = defineMessages({ id: 'project-type.shader.plural', defaultMessage: 'Shaders', }, + project: { + id: 'project-type.project.singular', + defaultMessage: 'Project', + }, + projects: { + id: 'project-type.project.plural', + defaultMessage: 'Projects', + }, }) type ExtractSingulars = K extends `${infer T}s` ? T : never @@ -54,5 +62,8 @@ type ExtractSingulars = K extends `${infer T}s` ? T : never type ProjectType = ExtractSingulars export function getProjectTypeMessage(type: ProjectType, plural = false) { - return projectTypeMessages[`${type}${plural ? 's' : ''}`] + return ( + projectTypeMessages[`${type}${plural ? 's' : ''}`] ?? + projectTypeMessages[`project${plural ? 's' : ''}`] + ) }