From a5e10a74d0cb705fcf0efff93afc54190a7d7c3d Mon Sep 17 00:00:00 2001 From: shay <43248357+shayypy@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:15:24 -0600 Subject: [PATCH] feat(bot): transformLocalizations w/ static locale --- packages/bot/src/cron.ts | 3 ++- packages/bot/src/util/l10n.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/bot/src/cron.ts b/packages/bot/src/cron.ts index 683dbe8..143926e 100644 --- a/packages/bot/src/cron.ts +++ b/packages/bot/src/cron.ts @@ -26,6 +26,7 @@ import { getTeamPartialEmoji } from "./util/emojis"; import { isDiscordError } from "./util/errors"; import { getNow } from "./util/time"; import type { Snowflake } from "discord-snowflake"; +import { uni } from "./util/l10n"; export type NotificationEntry = Pick< typeof notifications.$inferSelect, @@ -140,7 +141,7 @@ const runPickems = async ( try { const thread = (await rest.post(Routes.threads(entry.channelId), { body: { - name: `${league.toUpperCase()} Pickems - ${firstStart.toLocaleDateString( + name: `${uni("en", league)} Pickems - ${firstStart.toLocaleDateString( "en-US", { weekday: "short", diff --git a/packages/bot/src/util/l10n.ts b/packages/bot/src/util/l10n.ts index 53be4c7..23444fb 100644 --- a/packages/bot/src/util/l10n.ts +++ b/packages/bot/src/util/l10n.ts @@ -49,8 +49,10 @@ export const transformLocalizations = >( localizations: T, ) => - (ctx: InteractionContext, key: keyof T["en"]) => { - const locale = getKeyableLocale(ctx) as keyof T; + (ctx: InteractionContext | string, key: keyof T["en"]) => { + const locale = ( + typeof ctx === "string" ? ctx : getKeyableLocale(ctx) + ) as keyof T; const engStrings = localizations.en; const strings = localizations[locale]; if (strings && key in strings) {