From 495dbb09d58c1b1462592dce39afb4dbc94939d3 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 22 Feb 2024 13:45:55 +0100 Subject: [PATCH 01/22] feat: translate calendar --- frontend/messages/en.json | 22 ++++++++++- frontend/messages/fr.json | 21 +++++++++- .../lib/components/Calendar/Calendar.svelte | 38 ++++++++++--------- 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index faecb3f4e..4f1cd162a 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -172,6 +172,24 @@ "measureOpen": "Measure: open", "measureProgress": "Measure: in progress", "measureHold": "Measure: on hold", - "measureDone": "Measure: done" - + "measureDone": "Measure: done", + "monday": "Monday", + "tuesday": "Tuesday", + "wednesday": "Wednesday", + "thursday": "Thursday", + "friday": "Friday", + "saturday": "Saturday", + "sunday": "Sunday", + "january": "January", + "february": "February", + "march": "March", + "april": "April", + "may": "May", + "june": "June", + "july": "July", + "august": "August", + "september": "September", + "october": "October", + "november": "November", + "december": "December" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 124e7f29a..608838ad3 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -172,6 +172,25 @@ "measureOpen": "Mesure: ouverte", "measureProgress": "Mesure: en cours", "measureHold": "Mesure: en attente", - "measureDone": "Mesure: terminée" + "measureDone": "Mesure: terminée", + "monday": "Lundi", + "tuesday": "Mardi", + "wednesday": "Mercredi", + "thursday": "Jeudi", + "friday": "Vendredi", + "saturday": "Samedi", + "sunday": "Dimanche", + "january": "Janvier", + "february": "Février", + "march": "Mars", + "april": "Avril", + "may": "Mai", + "june": "Juin", + "july": "Juillet", + "august": "Août", + "september": "Septembre", + "october": "Octobre", + "november": "Novembre", + "december": "Décembre" } diff --git a/frontend/src/lib/components/Calendar/Calendar.svelte b/frontend/src/lib/components/Calendar/Calendar.svelte index a7af659ac..419f179e3 100644 --- a/frontend/src/lib/components/Calendar/Calendar.svelte +++ b/frontend/src/lib/components/Calendar/Calendar.svelte @@ -4,6 +4,8 @@ import Notifications from './Notifications.svelte'; import { showNotification } from '$lib/utils/stores'; + import * as m from '$paraglide/messages' + export let info: object[]; let showNotificationBool = JSON.parse($showNotification); @@ -14,20 +16,20 @@ let daysInMonth = new Date(year, month, 0).getDate(); let firstDay = new Date(year, month - 1, 1).getDay(); - const daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; + const daysOfWeek = [m.monday(), m.tuesday(), m.wednesday(), m.thursday(), m.friday(), m.saturday(), m.sunday()]; const monthNames = [ - 'january', - 'february', - 'march', - 'april', - 'may', - 'june', - 'july', - 'august', - 'september', - 'october', - 'november', - 'december' + m.january(), + m.february(), + m.march(), + m.april(), + m.may(), + m.june(), + m.july(), + m.august(), + m.september(), + m.october(), + m.november(), + m.december() ]; function todayDay() { @@ -112,19 +114,19 @@ class="font-light text-lg border rounded-lg border-white p-2 hover:bg-white text-white hover:text-primary-500 transition duration-300" > - Today + {m.today()} - + --> - {#if showNotificationBool} + From 6bfd51ad4d1878e27f1d3afb571d4999889e1105 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 22 Feb 2024 14:00:05 +0100 Subject: [PATCH 02/22] fix: authors and reviewers foreign keys --- frontend/src/lib/utils/crud.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index 98e52efc8..29258fb92 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -134,7 +134,9 @@ export const URL_MODEL_MAP: ModelMap = { { field: 'project', urlModel: 'projects' }, { field: 'auditor', urlModel: 'users' }, { field: 'risk_matrix', urlModel: 'risk-matrices' }, - { field: 'risk_scenarios', urlModel: 'risk-scenarios' } + { field: 'risk_scenarios', urlModel: 'risk-scenarios' }, + { field: 'authors', urlModel: 'users' }, + { field: 'reviewers', urlModel: 'users' } ], reverseForeignKeyFields: [{ field: 'risk_assessment', urlModel: 'risk-scenarios' }], filters: [{ field: 'project' }, { field: 'auditor' }] @@ -300,7 +302,9 @@ export const URL_MODEL_MAP: ModelMap = { verboseNamePlural: 'Compliance assessments', foreignKeyFields: [ { field: 'project', urlModel: 'projects' }, - { field: 'framework', urlModel: 'frameworks' } + { field: 'framework', urlModel: 'frameworks' }, + { field: 'authors', urlModel: 'users' }, + { field: 'reviewers', urlModel: 'users' } ] }, requirements: { From bd117e73f4863a7992232d404c8e512b30f64dc6 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 22 Feb 2024 14:09:39 +0100 Subject: [PATCH 03/22] fix: page title/breadcrumbs with objects name --- frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte index 6c72faf1d..2243a2100 100644 --- a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte +++ b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte @@ -22,21 +22,22 @@ $: { // Remove zero-length tokens. const tokens = $page.url.pathname.split('/').filter((t) => t !== ''); + let title = ''; // Create { label, href } pairs for each token. let tokenPath = ''; crumbs = tokens.map((t) => { tokenPath += '/' + t; if (t === $breadcrumbObject.id) { - if ($breadcrumbObject.name) t = $breadcrumbObject.name; - else t = $breadcrumbObject.email; + if ($breadcrumbObject.name) title = $breadcrumbObject.name; + else title = $breadcrumbObject.email; } else if (t === 'folders') { t = 'domains'; } t = t.replace(/-/g, ' '); t = capitalizeSecondWord(t); return { - label: $page.data.label || t, + label: $page.data.label || title || t, href: Object.keys(listViewFields).includes(tokens[0]) ? tokenPath : null }; }); From 2b01fac68208421acdcf5cf6f9ed475935be7534 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 22 Feb 2024 14:30:26 +0100 Subject: [PATCH 04/22] feat: translate x-rays page --- frontend/messages/en.json | 6 ++- frontend/messages/fr.json | 6 ++- .../components/ModelTable/ModelTable.svelte | 39 ++---------------- frontend/src/routes/(app)/x-rays/+page.svelte | 41 +++++++++++++++---- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 4f1cd162a..abda3c903 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -191,5 +191,9 @@ "september": "September", "october": "October", "november": "November", - "december": "December" + "december": "December", + "error": "error{s}", + "warning": "warning{s}", + "info": "info{s}", + "found": "found" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 608838ad3..add921484 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -191,6 +191,10 @@ "september": "Septembre", "october": "Octobre", "november": "Novembre", - "december": "Décembre" + "december": "Décembre", + "error": "erreur{s}", + "warning": "avertissement{s}", + "info": "info{s}", + "found": "trouvé{e}{s}" } diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 9cf6b7143..a8440f953 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -12,6 +12,8 @@ import type { AnyZodObject } from 'zod'; import type { TableSource } from './types'; import * as m from '$paraglide/messages'; + import { localItems } from '$lib/utils/locales'; + import { languageTag } from '$paraglide/runtime'; // Event Dispatcher type TableEvent = { selected: string[]; @@ -120,41 +122,6 @@ // tagged_keys tag_map[key][value] $: source, handler.setRows(data); - - const headTranslate: any = { - name: m.name(), - description: m.description(), - parentDomain: m.parentDomain(), - ref: m.ref(), - refId: m.refId(), - businessValue: m.businessValue(), - email: m.email(), - firstName: m.firstName(), - lastName: m.lastName(), - category: m.category(), - eta: m.eta(), - securityFunction: m.securityFunction(), - provider: m.provider(), - domain: m.domain(), - urn: m.urn(), - id: m.id(), - treatmentStatus: m.treatmentStatus(), - currentLevel: m.currentLevel(), - residualLevel: m.residualLevel(), - riskMatrix: m.riskMatrix(), - riskScenarios: m.riskScenarios(), - project: m.project(), - complianceAssessments: m.complianceAssessments(), - folder: m.folder(), - builtin: m.builtin(), - assets: m.assets(), - threat: m.threat(), - riskAssessment: m.riskAssessment(), - framework: m.framework(), - file: m.file(), - overview: m.overview(), - language: m.language() - }
@@ -181,7 +148,7 @@ {#each Object.entries(source.head) as [key, heading]} - {headTranslate[heading]} + {localItems(languageTag())[heading]} {/each} {#if displayActions} diff --git a/frontend/src/routes/(app)/x-rays/+page.svelte b/frontend/src/routes/(app)/x-rays/+page.svelte index 048e12283..cda308a6a 100644 --- a/frontend/src/routes/(app)/x-rays/+page.svelte +++ b/frontend/src/routes/(app)/x-rays/+page.svelte @@ -1,6 +1,7 @@ diff --git a/frontend/src/lib/components/Calendar/Calendar.svelte b/frontend/src/lib/components/Calendar/Calendar.svelte index 419f179e3..3750e2e61 100644 --- a/frontend/src/lib/components/Calendar/Calendar.svelte +++ b/frontend/src/lib/components/Calendar/Calendar.svelte @@ -4,7 +4,7 @@ import Notifications from './Notifications.svelte'; import { showNotification } from '$lib/utils/stores'; - import * as m from '$paraglide/messages' + import * as m from '$paraglide/messages'; export let info: object[]; @@ -16,7 +16,15 @@ let daysInMonth = new Date(year, month, 0).getDate(); let firstDay = new Date(year, month - 1, 1).getDay(); - const daysOfWeek = [m.monday(), m.tuesday(), m.wednesday(), m.thursday(), m.friday(), m.saturday(), m.sunday()]; + const daysOfWeek = [ + m.monday(), + m.tuesday(), + m.wednesday(), + m.thursday(), + m.friday(), + m.saturday(), + m.sunday() + ]; const monthNames = [ m.january(), m.february(), diff --git a/frontend/src/lib/components/Chart/DonutChart.svelte b/frontend/src/lib/components/Chart/DonutChart.svelte index 684edde32..38f56f66e 100644 --- a/frontend/src/lib/components/Chart/DonutChart.svelte +++ b/frontend/src/lib/components/Chart/DonutChart.svelte @@ -9,7 +9,7 @@ export let colors: string[] = []; for (const item in values) { - values[item]['name'] = localItems(languageTag())[values[item]['localName']] + values[item]['name'] = localItems(languageTag())[values[item]['localName']]; } let chart_element: HTMLElement | null = null; diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index ce1a165b7..0dfbf796b 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -126,7 +126,13 @@ field="reviewers" label={m.reviewers()} /> - + {:else if URLModel === 'security-measures' || URLModel === 'policies'} {#if schema.shape.category} - {/if} +