Skip to content

Commit 5c712e4

Browse files
committed
chore(i18n): review
1 parent d68fc00 commit 5c712e4

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

app/components/ColumnPicker.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ useEventListener('keydown', event => {
3737
const toggleableColumns = computed(() => props.columns.filter(col => col.id !== 'name'))
3838
3939
// Map column IDs to i18n keys
40-
const columnLabelKey: Record<string, string> = {
40+
const columnLabelKey = computed(() => ({
4141
name: $t('filters.columns.name'),
4242
version: $t('filters.columns.version'),
4343
description: $t('filters.columns.description'),
@@ -50,10 +50,10 @@ const columnLabelKey: Record<string, string> = {
5050
maintenanceScore: $t('filters.columns.maintenance_score'),
5151
combinedScore: $t('filters.columns.combined_score'),
5252
security: $t('filters.columns.security'),
53-
}
53+
}))
5454
55-
function getColumnLabel(id: string): string {
56-
const key = columnLabelKey[id]
55+
function getColumnLabel(id: ColumnId): string {
56+
const key = columnLabelKey.value[id]
5757
return key ?? id
5858
}
5959

app/components/Org/MembersPanel.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ function getRoleBadgeClass(role: string): string {
262262
}
263263
}
264264
265-
const roleLabels = {
265+
const roleLabels = computed(() => ({
266266
owner: $t('org.members.role.owner'),
267267
admin: $t('org.members.role.admin'),
268268
developer: $t('org.members.role.developer'),
269269
all: $t('org.members.role.all'),
270-
}
270+
}))
271271
272272
function getRoleLabel(role: MemberRoleFilter): string {
273-
return roleLabels[role]
273+
return roleLabels.value[role]
274274
}
275275
276276
// Click on team badge to switch to teams tab and highlight
@@ -473,9 +473,9 @@ watch(lastExecutionTime, () => {
473473
)
474474
"
475475
>
476-
<option value="developer">{{ $t('org.members.role.developer') }}</option>
477-
<option value="admin">{{ $t('org.members.role.admin') }}</option>
478-
<option value="owner">{{ $t('org.members.role.owner') }}</option>
476+
<option value="developer">{{ getRoleLabel('developer') }}</option>
477+
<option value="admin">{{ getRoleLabel('admin') }}</option>
478+
<option value="owner">{{ getRoleLabel('owner') }}</option>
479479
</select>
480480
<!-- Remove button -->
481481
<button

app/components/Package/DownloadAnalytics.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,15 +785,15 @@ function buildExportFilename(extension: string): string {
785785
return `${sanitise(label ?? '')}-${g}_${range}.${extension}`
786786
}
787787
788-
const granularityLabels = {
788+
const granularityLabels = computed(() => ({
789789
daily: $t('package.downloads.granularity_daily'),
790790
weekly: $t('package.downloads.granularity_weekly'),
791791
monthly: $t('package.downloads.granularity_monthly'),
792792
yearly: $t('package.downloads.granularity_yearly'),
793-
}
793+
}))
794794
795795
function getGranularityLabel(granularity: ChartTimeGranularity) {
796-
return granularityLabels[granularity]
796+
return granularityLabels.value[granularity]
797797
}
798798
799799
// VueUiXy chart component configuration

app/components/Package/VulnerabilityTree.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ const hasVulnerabilities = computed(
2323
// Banner - amber for better light mode contrast
2424
const bannerColor = 'border-amber-600/40 bg-amber-500/10 text-amber-700 dark:text-amber-400'
2525
26-
const severityLabels = {
26+
const severityLabels = computed(() => ({
2727
critical: $t('package.vulnerabilities.severity.critical'),
2828
high: $t('package.vulnerabilities.severity.high'),
2929
moderate: $t('package.vulnerabilities.severity.moderate'),
3030
low: $t('package.vulnerabilities.severity.low'),
31-
}
31+
}))
3232
3333
function getPackageSeverityLabel(severity: Exclude<OsvSeverityLevel, 'unknown'>) {
34-
return severityLabels[severity]
34+
return severityLabels.value[severity]
3535
}
3636
3737
const summaryText = computed(() => {

app/composables/useFacetSelection.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export interface FacetInfoWithLabels extends Omit<FacetInfo, 'id'> {
2323
export function useFacetSelection(queryParam = 'facets') {
2424
const { t } = useI18n()
2525

26-
const facetLabels = {
26+
const facetLabels = computed(() => ({
2727
downloads: {
2828
label: t(`compare.facets.items.downloads.label`),
29-
description: t(`compare.facets.items.downloads.label`),
29+
description: t(`compare.facets.items.downloads.description`),
3030
},
3131
packageSize: {
3232
label: t(`compare.facets.items.packageSize.label`),
@@ -72,15 +72,15 @@ export function useFacetSelection(queryParam = 'facets') {
7272
label: t(`compare.facets.items.deprecated.label`),
7373
description: t(`compare.facets.items.deprecated.description`),
7474
},
75-
}
75+
}))
7676

7777
// Helper to build facet info with i18n labels
7878
function buildFacetInfo(facet: ComparisonFacet): FacetInfoWithLabels {
7979
return {
8080
id: facet,
8181
...FACET_INFO[facet],
82-
label: facetLabels[facet].label,
83-
description: facetLabels[facet].description,
82+
label: facetLabels.value[facet].label,
83+
description: facetLabels.value[facet].description,
8484
}
8585
}
8686

scripts/find-invalid-translations.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,7 @@ async function run(): Promise<void> {
8989
}
9090
}
9191

92-
run()
92+
run().catch((error: unknown) => {
93+
console.error(colors.red('\n❌ Unexpected error:'), error)
94+
process.exit(1)
95+
})

0 commit comments

Comments
 (0)