ソースを参照

fix(dashboard): Localize filter badge start/end labels

Relates to #4004
Housein Abo Shaar 1 週間 前
コミット
19ff5c60b1

+ 15 - 1
packages/dashboard/src/lib/components/data-table/data-table-filter-badge.tsx

@@ -1,4 +1,5 @@
 import { useLocalFormat } from '@/vdb/hooks/use-local-format.js';
+import { Trans } from '@lingui/react/macro';
 import { Filter, XIcon } from 'lucide-react';
 import { Badge } from '../ui/badge.js';
 import { HumanReadableOperator, Operator } from './human-readable-operator.js';
@@ -58,7 +59,9 @@ function FilterValue({
     if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
         return Object.entries(value as Record<string, unknown>).map(([key, value]) => (
             <div key={key} className="flex gap-1 items-center">
-                <span className="text-muted-foreground">{key}: </span>
+                <span className="text-muted-foreground">
+                    <FilterKeyLabel filterKey={key} />:{' '}
+                </span>
                 <FilterValue value={value} dataType={dataType} currencyCode={currencyCode} />
             </div>
         ));
@@ -99,3 +102,14 @@ function FilterValue({
 function isDateIsoString(value: string) {
     return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value);
 }
+
+function FilterKeyLabel({ filterKey }: { filterKey: string }) {
+    switch (filterKey) {
+        case 'start':
+            return <Trans>start</Trans>;
+        case 'end':
+            return <Trans>end</Trans>;
+        default:
+            return <>{filterKey}</>;
+    }
+}