Skip to content

Commit

Permalink
feat(bot): transformLocalizations w/ static locale
Browse files Browse the repository at this point in the history
  • Loading branch information
shayypy committed Nov 8, 2024
1 parent ff8b66e commit a5e10a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/bot/src/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions packages/bot/src/util/l10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ export const transformLocalizations =
>(
localizations: T,
) =>
(ctx: InteractionContext<APIInteraction>, key: keyof T["en"]) => {
const locale = getKeyableLocale(ctx) as keyof T;
(ctx: InteractionContext<APIInteraction> | 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) {
Expand Down

0 comments on commit a5e10a7

Please sign in to comment.