diff --git a/src/components/Discover/DiscoverTvUpcoming.tsx b/src/components/Discover/DiscoverTvUpcoming.tsx index 182cd1a54..a6a3be170 100644 --- a/src/components/Discover/DiscoverTvUpcoming.tsx +++ b/src/components/Discover/DiscoverTvUpcoming.tsx @@ -7,7 +7,9 @@ import defineMessages from '@app/utils/defineMessages'; import type { TvResult } from '@server/models/Search'; import { useIntl } from 'react-intl'; -const messages = defineMessages('components.DiscoverTvUpcoming', {}); +const messages = defineMessages('components.DiscoverTvUpcoming', { + upcomingtv: 'Upcoming Series', +}); const DiscoverTvUpcoming = () => { const intl = useIntl(); diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 9453d39ed..3fce7abd7 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -100,6 +100,7 @@ "components.Discover.StudioSlider.studios": "Studios", "components.Discover.TvGenreList.seriesgenres": "Series Genres", "components.Discover.TvGenreSlider.tvgenres": "Series Genres", + "components.DiscoverTvUpcoming.upcomingtv": "Upcoming Series", "components.Discover.createnewslider": "Create New Slider", "components.Discover.customizediscover": "Customize Discover", "components.Discover.discover": "Discover", diff --git a/src/utils/defineMessages.ts b/src/utils/defineMessages.ts index 69a04a7d5..bb8fadb4b 100644 --- a/src/utils/defineMessages.ts +++ b/src/utils/defineMessages.ts @@ -1,18 +1,26 @@ import { defineMessages as intlDefineMessages } from 'react-intl'; -export default function defineMessages( +type Messages> = { + [K in keyof T]: { + id: string; + defaultMessage: T[K]; + }; +}; + +export default function defineMessages>( prefix: string, - messages: Record -) { - const modifiedMessages: Record< - string, - { id: string; defaultMessage: string } - > = {}; - for (const key of Object.keys(messages)) { - modifiedMessages[key] = { - id: prefix + '.' + key, + messages: T +): Messages { + const keys: (keyof T)[] = Object.keys(messages); + const modifiedMessagesEntries = keys.map((key) => [ + key, + { + id: `${prefix}.${key as string}`, defaultMessage: messages[key], - }; - } + }, + ]); + const modifiedMessages: Messages = Object.fromEntries( + modifiedMessagesEntries + ); return intlDefineMessages(modifiedMessages); }