Skip to content

Commit

Permalink
fix: correctly access some i18n labels
Browse files Browse the repository at this point in the history
  • Loading branch information
fspoettel committed Feb 22, 2025
1 parent eb62195 commit 5ef279e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/components/deck-tools/limited-slots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ListCard } from "../list-card/list-card";

export function LimitedSlots(props: { deck: ResolvedDeck }) {
const { t } = useTranslation();

const limitedSlots = useStore((state) =>
selectLimitedSlotOccupation(state, props.deck),
);
Expand Down Expand Up @@ -34,7 +35,11 @@ export function LimitedSlots(props: { deck: ResolvedDeck }) {
quantity={quantity}
/>
)}
title={entry.option.name ?? t("deck.limited_slots")}
title={
entry.option.name
? t(`common.deck_options.${entry.option.name}`)
: t("deck.limited_slots")
}
/>
))}
</>
Expand Down
24 changes: 14 additions & 10 deletions src/store/selectors/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1242,17 +1242,20 @@ export const selectSkillIconsChanges = (value: SkillIconsFilter) => {
* Subtype
*/

const subtypeLabels: Record<string, string> = {
none: i18n.t("common.subtype.none"),
weakness: i18n.t("common.subtype.weakness"),
basicweakness: i18n.t("common.subtype.basicweakness"),
};
function subtypeLabels() {
return {
none: i18n.t("common.subtype.none"),
weakness: i18n.t("common.subtype.weakness"),
basicweakness: i18n.t("common.subtype.basicweakness"),
} as Record<string, string>;
}

export function selectSubtypeOptions() {
const labels = subtypeLabels();
return [
{ code: "none", name: subtypeLabels["none"] },
{ code: "weakness", name: subtypeLabels["weakness"] },
{ code: "basicweakness", name: subtypeLabels["basicweakness"] },
{ code: "none", name: labels["none"] },
{ code: "weakness", name: labels["weakness"] },
{ code: "basicweakness", name: labels["basicweakness"] },
];
}

Expand All @@ -1261,12 +1264,13 @@ export const selectSubtypeChanges = createSelector(
(value) => {
const options = Object.entries(value);
const enabled = options.filter(([, value]) => !!value);
const labels = subtypeLabels();

if (enabled.length === 0) return subtypeLabels["none"];
if (enabled.length === 0) return labels["none"];
if (enabled.length === options.length) return "";

return enabled
.map(([key]) => subtypeLabels[key])
.map(([key]) => labels[key])
.join(` ${i18n.t("filters.or")} `);
},
);
Expand Down

0 comments on commit 5ef279e

Please sign in to comment.