Skip to content

Commit 8078d4d

Browse files
seferturantrakt-bot[bot]
authored andcommitted
fix(list): internationalize and improve range filter summaries
Adds new i18n messages for upper-bound-only range filters (e.g., "Up to 90"). Introduces locale-aware percentage formatting for all smart list range filter summaries, ensuring percentage values are displayed correctly according to the user's locale. Changes from ranges to be worded to kill bidi risks.
1 parent 84e8b43 commit 8078d4d

2 files changed

Lines changed: 97 additions & 6 deletions

File tree

projects/client/i18n/meta/en.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6963,6 +6963,75 @@
69636963
}
69646964
}
69656965
},
6966+
"list_summary_range_up_to": {
6967+
"default": "Up to {value}",
6968+
"description": "Smart list filter summary for an upper-bound-only range, e.g. 'Up to 90'.",
6969+
"variables": {
6970+
"value": {
6971+
"type": "string"
6972+
}
6973+
}
6974+
},
6975+
"list_summary_range_labeled_up_to": {
6976+
"default": "{label} up to {value}",
6977+
"description": "Smart list filter summary for a labeled upper-bound-only range, e.g. 'Trakt up to 80%'.",
6978+
"variables": {
6979+
"label": {
6980+
"type": "string"
6981+
},
6982+
"value": {
6983+
"type": "string"
6984+
}
6985+
}
6986+
},
6987+
"list_summary_range_between": {
6988+
"default": "{min} to {max}",
6989+
"description": "Smart list filter summary for a range with both bounds, e.g. '60 to 80'.",
6990+
"variables": {
6991+
"min": {
6992+
"type": "string"
6993+
},
6994+
"max": {
6995+
"type": "string"
6996+
}
6997+
}
6998+
},
6999+
"list_summary_range_labeled_between": {
7000+
"default": "{label} {min} to {max}",
7001+
"description": "Smart list filter summary for a labeled range with both bounds, e.g. 'Trakt 60% to 80%'.",
7002+
"variables": {
7003+
"label": {
7004+
"type": "string"
7005+
},
7006+
"min": {
7007+
"type": "string"
7008+
},
7009+
"max": {
7010+
"type": "string"
7011+
}
7012+
}
7013+
},
7014+
"list_summary_range_from": {
7015+
"default": "{value} and up",
7016+
"description": "Smart list filter summary for a lower-bound-only range, e.g. '60 and up'.",
7017+
"variables": {
7018+
"value": {
7019+
"type": "string"
7020+
}
7021+
}
7022+
},
7023+
"list_summary_range_labeled_from": {
7024+
"default": "{label} {value} and up",
7025+
"description": "Smart list filter summary for a labeled lower-bound-only range, e.g. 'Trakt 60% and up'.",
7026+
"variables": {
7027+
"label": {
7028+
"type": "string"
7029+
},
7030+
"value": {
7031+
"type": "string"
7032+
}
7033+
}
7034+
},
69667035
"warning_smart_lists_limit": {
69677036
"default": "You've reached your smart list limit",
69687037
"description": "Warning text shown when a user has reached their smart list limit and attempts to create a new smart list."

projects/client/src/lib/sections/lists/smart/_internal/SmartListSummaryItem.svelte

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import MovieIcon from "$lib/components/icons/MovieIcon.svelte";
33
import ShowIcon from "$lib/components/icons/ShowIcon.svelte";
44
import Link from "$lib/components/link/Link.svelte";
5+
import { languageTag } from "$lib/features/i18n/index.ts";
56
import * as m from "$lib/features/i18n/messages.ts";
67
import CrossOriginImage from "$lib/features/image/components/CrossOriginImage.svelte";
78
import type { SmartList } from "$lib/requests/queries/users/smartListQuery.ts";
89
import ListSummaryCard from "$lib/sections/lists/components/ListSummaryCard.svelte";
10+
import { toPercentage } from "$lib/utils/formatting/number/toPercentage.ts";
911
import { toTranslatedGenre } from "$lib/utils/formatting/string/toTranslatedGenre";
1012
import { UrlBuilder } from "$lib/utils/url/UrlBuilder";
1113
import SmartListActions from "./SmartListActions.svelte";
@@ -65,33 +67,53 @@
6567
const [min, max] = value.split("-");
6668
6769
if (min && max) {
68-
return `${min}-${max}`;
70+
return m.list_summary_range_between({ min, max });
6971
}
7072
7173
if (min) {
72-
return `${min}+`;
74+
return m.list_summary_range_from({ value: min });
7375
}
7476
7577
if (max) {
76-
return `Up to ${max}`;
78+
return m.list_summary_range_up_to({ value: max });
7779
}
7880
7981
return value;
8082
}
8183
84+
function toRatingPercentage(value: string): string {
85+
const numeric = Number(value);
86+
87+
if (Number.isNaN(numeric)) {
88+
return value;
89+
}
90+
91+
return toPercentage(numeric / 100, languageTag());
92+
}
93+
8294
function formatPercentRange(value: string, label: string): string {
8395
const [min, max] = value.split("-");
8496
8597
if (min && max) {
86-
return `${label} ${min}-${max}%`;
98+
return m.list_summary_range_labeled_between({
99+
label,
100+
min: toRatingPercentage(min),
101+
max: toRatingPercentage(max),
102+
});
87103
}
88104
89105
if (min) {
90-
return `${label} ${min}%+`;
106+
return m.list_summary_range_labeled_from({
107+
label,
108+
value: toRatingPercentage(min),
109+
});
91110
}
92111
93112
if (max) {
94-
return `${label} up to ${max}%`;
113+
return m.list_summary_range_labeled_up_to({
114+
label,
115+
value: toRatingPercentage(max),
116+
});
95117
}
96118
97119
return `${label} ${value}`;

0 commit comments

Comments
 (0)