From fa49f8338254db770d8847e01520ad94f3f6e148 Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov <186095128+alexandr-garbuzov@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:55:20 +0300 Subject: [PATCH] refactor: move long locales const to the top and infer types (#4577) Co-authored-by: Alexandr --- backend/src/cards/stats.js | 57 +++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/backend/src/cards/stats.js b/backend/src/cards/stats.js index 5290dd13..5b13ff9c 100644 --- a/backend/src/cards/stats.js +++ b/backend/src/cards/stats.js @@ -21,6 +21,36 @@ const RANK_CARD_DEFAULT_WIDTH = 450; const RANK_ONLY_CARD_MIN_WIDTH = 290; const RANK_ONLY_CARD_DEFAULT_WIDTH = 290; +/** + * Long locales that need more space for text. Keep sorted alphabetically. + * + * @type {(keyof typeof wakatimeCardLocales["wakatimecard.title"])[]} + */ +const LONG_LOCALES = [ + "az", + "bg", + "cs", + "de", + "es", + "fil", + "fr", + "id", + "ml", + "my", + "nl", + "pl", + "pt-br", + "pt-pt", + "ru", + "sr", + "sr-latn", + "sw", + "ta", + "uk-ua", + "uz", + "zh-tw", +]; + /** * Create a stats card text item. * @@ -447,31 +477,8 @@ const renderStatsCard = ( id: "contribs", }; - const longLocales = [ - "az", - "bg", - "cs", - "de", - "es", - "fil", - "fr", - "id", - "ml", - "my", - "nl", - "pl", - "pt-br", - "pt-pt", - "ru", - "sr", - "sr-latn", - "sw", - "ta", - "uk-ua", - "uz", - "zh-tw", - ]; - const isLongLocale = locale ? longLocales.includes(locale) : false; + // @ts-ignore + const isLongLocale = locale ? LONG_LOCALES.includes(locale) : false; // check if all used labels are short const longLabels =