Skip to content

Commit 17c134f

Browse files
authored
Merge pull request #107 from NGO-Algorithm-Audit/feature/changes-15-jun-sdg
Column headers in table are translatable when needed
2 parents 2b17b4d + bae4900 commit 17c134f

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

src/assets/synthetic-data.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ def run():
262262
'titleKey': 'syntheticData.handlingMissingDataTableTitle',
263263
'showIndex' : False,
264264
'data': missingness_dict_df.to_json(orient="records"),
265-
'noTableBelowTable': True
265+
'noTableBelowTable': True,
266+
'translateColumnHeaders': True,
267+
'translatePrefix': 'missingData.'
266268
},
267269
{
268270
'reportType': 'text',
@@ -333,7 +335,8 @@ def run():
333335
'contentType': 'text',
334336
'text': f"Score: {dp_score:.3f}"
335337
}],
336-
'data': dp_report_df.to_json(orient="records"),
338+
'data': dp_report_df.to_json(orient="records"),
339+
'translateColumnHeaders': True
337340
}
338341
]
339342
}))

src/components/DistributionReport.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ interface DistributionReport {
7575
postContent?: string;
7676
noTableBelowTable?: boolean;
7777
noHTML?: boolean;
78+
translateColumnHeaders?: boolean;
79+
translatePrefix?: string;
7880
}
7981
export interface DistributionReportProps {
8082
dataTypes: string;
@@ -185,6 +187,12 @@ export const DistributionReport = (
185187
noTableBelowTable={
186188
report.noTableBelowTable
187189
}
190+
translateColumnHeaders={
191+
report.translateColumnHeaders
192+
}
193+
translatePrefix={
194+
report.translatePrefix
195+
}
188196
/>
189197
{report.postContent &&
190198
postContent.map(

src/components/SimpleTable.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ export default function SimpleTable({
1515
showIndex,
1616
translate,
1717
noTableBelowTable,
18+
translateColumnHeaders,
19+
translatePrefix,
1820
}: {
1921
showIndex: boolean;
2022
title?: string;
2123
data: Record<string, string | number>[];
2224
translate?: boolean;
2325
noTableBelowTable?: boolean;
26+
translateColumnHeaders?: boolean;
27+
translatePrefix?: string;
2428
}) {
2529
const { t } = useTranslation();
2630
// limit data to the first 100 rows.
@@ -37,7 +41,9 @@ export default function SimpleTable({
3741
{showIndex && <TableHead></TableHead>}
3842
{Object.keys(data[0]).map(key => (
3943
<TableHead key={key} className="text-black">
40-
{translate ? t(key) : key}
44+
{translate || translateColumnHeaders
45+
? t(`${translatePrefix ?? ''}${key}`)
46+
: key}
4147
</TableHead>
4248
))}
4349
</TableRow>

src/locales/en.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ export const en = {
2222
installingPackages: 'Installing additional packages...',
2323
runningAnalysis: 'Running analysis...',
2424
categorical: 'Categorical',
25-
numerical: 'Numerical',
25+
numerical: 'numerical',
26+
threshold: 'threshold',
27+
risk_rate: 'risk_rate',
28+
disclosure_protection_score: 'disclosure_protection_score',
29+
missingData: {
30+
Column: 'Column',
31+
'Missing data type': 'Missing data type',
32+
},
2633
biasSettings: {
2734
dataType: {
2835
numeric: 'Numeric',

src/locales/nl.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ export const nl = {
2020
runningAnalysis: 'Analyse uitvoeren...',
2121
categorical: 'Categorisch',
2222
numerical: 'Numeriek',
23+
threshold: 'drempelwaarde',
24+
risk_rate: 'risk_rate',
25+
disclosure_protection_score: 'disclosure_protection_score',
26+
missingData: {
27+
Column: 'Kolom',
28+
'Missing data type': 'Type missende data',
29+
},
2330
biasSettings: {
2431
dataType: {
2532
numeric: 'Numeriek',

0 commit comments

Comments
 (0)