From 7c8b275994c243d956b43650af1ca3cea4f7b854 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 13 Feb 2024 15:12:47 +0100 Subject: [PATCH 01/19] feat: prepare sidebar translations --- frontend/messages/en.json | 33 +++++++++- frontend/messages/fr.json | 10 +++- .../components/Breadcrumbs/Breadcrumbs.svelte | 2 +- .../components/SideBar/SideBarCategory.svelte | 19 ++++-- .../lib/components/SideBar/SideBarItem.svelte | 28 ++++++++- .../src/lib/components/SideBar/navData.ts | 60 +++++++++---------- 6 files changed, 112 insertions(+), 40 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 5816b0994..ca5fcf337 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1,5 +1,34 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", - "Home": "Home", - "Overview": "Overview" + "home": "Home", + "overview": "Overview", + "context": "Context", + "governance": "Governance", + "risk": "Risk", + "compliance": "Compliance", + "organisation": "Organisation", + "extra": "Extra", + "analytics": "Analytics", + "calendar": "Calendar", + "threats": "Threats", + "securityFunctions": "Security functions", + "securityMeasures": "Security measures", + "assets": "Assets", + "policies": "Policies", + "riskMatrices": "Risk matrices", + "riskAssessments": "Risk assessments", + "riskScenarios": "Risk scenarios", + "riskAcceptances": "Risk acceptances", + "complianceAssessments": "Compliance assessments", + "evidences": "Evidences", + "frameworks": "Frameworks", + "domains": "Domains", + "projects": "Projects", + "users": "Users", + "userGroups": "User groups", + "roleAssignments": "Role assignments", + "xrays": "X-rays", + "scoringAssistant": "Scoring assistant", + "libraries": "Libraries", + "backupRestore": "Backup & restore" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 4d4a17a3f..2c0ad379f 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1,5 +1,11 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", - "Home": "Accueil", - "Overview": "Vue d'ensemble" + "home": "Accueil", + "overview": "Vue d'ensemble", + "context": "Contexte", + "governance": "Gouvernance", + "risk": "Risque", + "compliance": "Conformité", + "organisation": "Organisation", + "extra": "Extra" } diff --git a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte index c6bcd2690..1e59d9d1a 100644 --- a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte +++ b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte @@ -28,7 +28,7 @@ }; }); - crumbs.unshift({ label: m.Home(), href: '/', icon: 'fa-regular fa-compass' }); + crumbs.unshift({ label: m.home(), href: '/', icon: 'fa-regular fa-compass' }); if (crumbs[crumbs.length - 1].label != 'Edit') pageTitle.set(crumbs[crumbs.length - 1].label); else pageTitle.set('Edit ' + crumbs[crumbs.length - 2].label); } diff --git a/frontend/src/lib/components/SideBar/SideBarCategory.svelte b/frontend/src/lib/components/SideBar/SideBarCategory.svelte index 24c5a2ceb..67373edd5 100644 --- a/frontend/src/lib/components/SideBar/SideBarCategory.svelte +++ b/frontend/src/lib/components/SideBar/SideBarCategory.svelte @@ -1,7 +1,18 @@ -{item.name} + + {sidebar[item.name]} + diff --git a/frontend/src/lib/components/SideBar/SideBarItem.svelte b/frontend/src/lib/components/SideBar/SideBarItem.svelte index 760167962..3676cc7ce 100644 --- a/frontend/src/lib/components/SideBar/SideBarItem.svelte +++ b/frontend/src/lib/components/SideBar/SideBarItem.svelte @@ -1,12 +1,38 @@ {#each item as item} diff --git a/frontend/src/lib/components/SideBar/navData.ts b/frontend/src/lib/components/SideBar/navData.ts index 3148d6c31..f85cd867f 100644 --- a/frontend/src/lib/components/SideBar/navData.ts +++ b/frontend/src/lib/components/SideBar/navData.ts @@ -12,10 +12,10 @@ export const navData = { // ] // }, { - name: 'Overview', + name: "overview", items: [ { - name: 'Analytics', + name: 'analytics', fa_icon: 'fa-solid fa-gauge', href: '/analytics', permissions: [ @@ -27,7 +27,7 @@ export const navData = { ] }, { - name: 'Calendar', + name: 'calendar', fa_icon: 'fa-solid fa-calendar-days', href: '/calendar', permissions: ['view_event'] @@ -35,60 +35,60 @@ export const navData = { ] }, { - name: 'Context', + name: 'context', items: [ { - name: 'Threats', + name: 'threats', fa_icon: 'fa-solid fa-biohazard', href: '/threats' }, { - name: 'Security functions', + name: 'securityFunctions', fa_icon: 'fa-solid fa-gears', href: '/security-functions' }, { - name: 'Security measures', + name: 'securityMeasures', fa_icon: 'fa-solid fa-fire-extinguisher', href: '/security-measures' }, { - name: 'Assets', + name: 'assets', fa_icon: 'fa-solid fa-gem', href: '/assets' } ] }, { - name: 'Governance', + name: 'governance', items: [ { - name: 'Policies', + name: 'policies', fa_icon: 'fa-solid fa-user', href: '/security-measures' }, { - name: 'Risk matrices', + name: 'riskMatrices', fa_icon: 'fa-solid fa-table-cells-large', href: '/risk-matrices' } ] }, { - name: 'Risk', + name: 'risk', items: [ { - name: 'Risk assessments', + name: 'riskAssessments', fa_icon: 'fa-solid fa-magnifying-glass-chart', href: '/risk-assessments' }, { - name: 'Risk scenarios', + name: 'riskScenarios', fa_icon: 'fa-solid fa-clone', href: '/risk-scenarios' }, { - name: 'Risk acceptances', + name: 'riskAcceptances', fa_icon: 'fa-solid fa-user-tie', href: '/risk-acceptances' } @@ -96,50 +96,50 @@ export const navData = { }, { - name: 'Compliance', + name: 'compliance', items: [ { - name: 'Compliance assessments', + name: 'complianceAssessments', fa_icon: 'fa-solid fa-arrows-to-eye', href: '/compliance-assessments' }, { - name: 'Evidences', + name: 'evidences', fa_icon: 'fa-solid fa-file', href: '/evidences' }, { - name: 'Frameworks', + name: 'frameworks', fa_icon: 'fa-solid fa-folder', href: '/frameworks' } ] }, { - name: 'Organisation', + name: 'organisation', items: [ { - name: 'Domains', + name: 'domains', fa_icon: 'fa-solid fa-diagram-project', href: '/folders' }, { - name: 'Projects', + name: 'projects', fa_icon: 'fa-solid fa-cubes', href: '/projects' }, { - name: 'Users', + name: 'users', fa_icon: 'fa-solid fa-user', href: '/users' }, { - name: 'User groups', + name: 'userGroups', fa_icon: 'fa-solid fa-users', href: '/user-groups' }, { - name: 'Role assignments', + name: 'roleAssignments', fa_icon: 'fa-solid fa-user-tag', href: '/role-assignments' } @@ -147,28 +147,28 @@ export const navData = { }, { - name: 'Extra', + name: 'extra', items: [ { - name: 'X-Rays', + name: 'xrays', fa_icon: 'fa-solid fa-bolt', href: '/x-rays', permissions: ['view_riskassessment', 'view_assessment'] }, { - name: 'Scoring assistant', + name: 'scoringAssistant', fa_icon: 'fa-solid fa-star-half-stroke', href: '/scoring-assistant', permissions: ['view_riskmatrix'] }, { - name: 'Libraries', + name: 'libraries', fa_icon: 'fa-solid fa-folder-plus', href: '/libraries', permissions: ['add_threat', 'add_riskmatrix', 'add_securityfunction', 'add_framework'] }, { - name: 'Backup & restore', + name: 'backupRestore', fa_icon: 'fa-solid fa-floppy-disk', href: '/backup-restore', permissions: ['backup'] From 845387750f0b883b07b1ad90933f7f7aa1ccb8bd Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 13 Feb 2024 15:35:47 +0100 Subject: [PATCH 02/19] feat: add sidebar items french translation --- frontend/messages/fr.json | 25 ++++++++++++++++++- .../lib/components/SideBar/SideBarItem.svelte | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 2c0ad379f..3b3a017b1 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -7,5 +7,28 @@ "risk": "Risque", "compliance": "Conformité", "organisation": "Organisation", - "extra": "Extra" + "extra": "Extra", + "analytics": "Analytiques", + "calendar": "Calendrier", + "threats": "Menaces", + "securityFunctions": "Fonctions de sécurité", + "securityMeasures": "Mesures de sécurité", + "assets": "Biens sensibles", + "policies": "Politiques", + "riskMatrices": "Matrices de risque", + "riskAssessments": "Évaluations de risque", + "riskScenarios": "Scénarios de risque", + "riskAcceptances": "Acceptations de risque", + "complianceAssessments": "Évaluations de conformité", + "evidences": "Preuves", + "frameworks": "Cadres", + "domains": "Domaines", + "projects": "Projets", + "users": "Utilisateurs", + "userGroups": "Groupes d'utilisateurs", + "roleAssignments": "Affectations de rôle", + "xrays": "X-rays", + "scoringAssistant": "Assistat d'évaluation", + "libraries": "Bibliothèques", + "backupRestore": "Sauvegarde et restauration" } diff --git a/frontend/src/lib/components/SideBar/SideBarItem.svelte b/frontend/src/lib/components/SideBar/SideBarItem.svelte index 3676cc7ce..c0374eac3 100644 --- a/frontend/src/lib/components/SideBar/SideBarItem.svelte +++ b/frontend/src/lib/components/SideBar/SideBarItem.svelte @@ -45,7 +45,7 @@ > - {item.name} + {items[item.name]} {/each} From 81c752ceb9bac58a40b7eabaa196f7a71115db7b Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 13 Feb 2024 16:06:46 +0100 Subject: [PATCH 03/19] feat: translate breadcrumbs and page title --- frontend/messages/en.json | 3 +- frontend/messages/fr.json | 3 +- .../components/Breadcrumbs/Breadcrumbs.svelte | 62 +++++++++++++++++-- .../lib/components/SideBar/SideBarItem.svelte | 4 +- .../src/lib/components/SideBar/navData.ts | 2 +- frontend/src/routes/(app)/+layout.svelte | 36 ++++++++++- 6 files changed, 98 insertions(+), 12 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index ca5fcf337..49e03b9e1 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1,6 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", "home": "Home", + "edit": "Edit", "overview": "Overview", "context": "Context", "governance": "Governance", @@ -27,7 +28,7 @@ "users": "Users", "userGroups": "User groups", "roleAssignments": "Role assignments", - "xrays": "X-rays", + "xRays": "X-rays", "scoringAssistant": "Scoring assistant", "libraries": "Libraries", "backupRestore": "Backup & restore" diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 3b3a017b1..e84cffae9 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1,6 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", "home": "Accueil", + "edit": "Modifier", "overview": "Vue d'ensemble", "context": "Contexte", "governance": "Gouvernance", @@ -27,7 +28,7 @@ "users": "Utilisateurs", "userGroups": "Groupes d'utilisateurs", "roleAssignments": "Affectations de rôle", - "xrays": "X-rays", + "xRays": "X-rays", "scoringAssistant": "Assistat d'évaluation", "libraries": "Bibliothèques", "backupRestore": "Sauvegarde et restauration" diff --git a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte index 1e59d9d1a..1805fe609 100644 --- a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte +++ b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte @@ -4,8 +4,46 @@ import { listViewFields } from '$lib/utils/table'; import * as m from '$paraglide/messages'; + const breadcrumbsItems: any = { + edit: m.edit(), + analytics: m.analytics(), + calendar: m.calendar(), + threats: m.threats(), + securityFunctions: m.securityFunctions(), + securityMeasures: m.securityMeasures(), + assets: m.assets(), + policies: m.policies(), + riskMatrices: m.riskMatrices(), + riskAssessments: m.riskAssessments(), + riskScenarios: m.riskScenarios(), + riskAcceptances: m.riskAcceptances(), + complianceAssessments: m.complianceAssessments(), + evidences: m.evidences(), + frameworks: m.frameworks(), + domains: m.domains(), + projects: m.projects(), + users: m.users(), + userGroups: m.userGroups(), + roleAssignments: m.roleAssignments(), + xRays: m.xRays(), + scoringAssistant: m.scoringAssistant(), + libraries: m.libraries(), + backupRestore: m.backupRestore() + } + let crumbs: Array<{ label: string; href: string; icon?: string }> = []; + function capitalizeSecondWord(sentence: string) { + var words = sentence.split(' '); + + if (words.length >= 2) { + words[1] = words[1].charAt(0).toUpperCase() + words[1].substring(1); + return words.join(''); + } else { + return sentence; + } +} + $: { // Remove zero-length tokens. const tokens = $page.url.pathname.split('/').filter((t) => t !== ''); @@ -20,8 +58,8 @@ } else if (t === 'folders') { t = 'domains'; } - t = t.charAt(0).toUpperCase() + t.slice(1); t = t.replace(/-/g, ' '); + t = capitalizeSecondWord(t); return { label: $page.data.label || t, href: Object.keys(listViewFields).includes(tokens[0]) ? tokenPath : null @@ -29,8 +67,8 @@ }); crumbs.unshift({ label: m.home(), href: '/', icon: 'fa-regular fa-compass' }); - if (crumbs[crumbs.length - 1].label != 'Edit') pageTitle.set(crumbs[crumbs.length - 1].label); - else pageTitle.set('Edit ' + crumbs[crumbs.length - 2].label); + if (crumbs[crumbs.length - 1].label != 'edit') pageTitle.set(crumbs[crumbs.length - 1].label); + else pageTitle.set(m.edit()+ ' ' + crumbs[crumbs.length - 2].label); } @@ -41,7 +79,11 @@ {#if c.icon} {/if} - {c.label} + {#if breadcrumbsItems[c.label]} + {breadcrumbsItems[c.label]} + {:else} + {c.label} + {/if} {:else}
  • @@ -53,14 +95,22 @@ {#if c.icon} {/if} - {c.label} + {#if breadcrumbsItems[c.label]} + {breadcrumbsItems[c.label]} + {:else} + {c.label} + {/if} {:else} {#if c.icon} {/if} - {c.label} + {#if breadcrumbsItems[c.label]} + {breadcrumbsItems[c.label]} + {:else} + {c.label} + {/if} {/if}
  • diff --git a/frontend/src/lib/components/SideBar/SideBarItem.svelte b/frontend/src/lib/components/SideBar/SideBarItem.svelte index c0374eac3..150ccb2ae 100644 --- a/frontend/src/lib/components/SideBar/SideBarItem.svelte +++ b/frontend/src/lib/components/SideBar/SideBarItem.svelte @@ -15,7 +15,7 @@ securityFunctions: m.securityFunctions(), securityMeasures: m.securityMeasures(), assets: m.assets(), - policies: m.policies(), // Note: Correcting typo in "policies" + policies: m.policies(), riskMatrices: m.riskMatrices(), riskAssessments: m.riskAssessments(), riskScenarios: m.riskScenarios(), @@ -28,7 +28,7 @@ users: m.users(), userGroups: m.userGroups(), roleAssignments: m.roleAssignments(), - xrays: m.xrays(), + xRays: m.xRays(), scoringAssistant: m.scoringAssistant(), libraries: m.libraries(), backupRestore: m.backupRestore() diff --git a/frontend/src/lib/components/SideBar/navData.ts b/frontend/src/lib/components/SideBar/navData.ts index f85cd867f..0f6a8de56 100644 --- a/frontend/src/lib/components/SideBar/navData.ts +++ b/frontend/src/lib/components/SideBar/navData.ts @@ -150,7 +150,7 @@ export const navData = { name: 'extra', items: [ { - name: 'xrays', + name: 'xRays', fa_icon: 'fa-solid fa-bolt', href: '/x-rays', permissions: ['view_riskassessment', 'view_assessment'] diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelte index 3d7e9aa4c..2e9ec50ad 100644 --- a/frontend/src/routes/(app)/+layout.svelte +++ b/frontend/src/routes/(app)/+layout.svelte @@ -7,8 +7,36 @@ import Breadcrumbs from '$lib/components/Breadcrumbs/Breadcrumbs.svelte'; import { pageTitle } from '$lib/utils/stores'; + import * as m from '$paraglide/messages'; + let sidebarOpen = true; + const items: any = { + analytics: m.analytics(), + calendar: m.calendar(), + threats: m.threats(), + securityFunctions: m.securityFunctions(), + securityMeasures: m.securityMeasures(), + assets: m.assets(), + policies: m.policies(), + riskMatrices: m.riskMatrices(), + riskAssessments: m.riskAssessments(), + riskScenarios: m.riskScenarios(), + riskAcceptances: m.riskAcceptances(), + complianceAssessments: m.complianceAssessments(), + evidences: m.evidences(), + frameworks: m.frameworks(), + domains: m.domains(), + projects: m.projects(), + users: m.users(), + userGroups: m.userGroups(), + roleAssignments: m.roleAssignments(), + xRays: m.xRays(), + scoringAssistant: m.scoringAssistant(), + libraries: m.libraries(), + backupRestore: m.backupRestore() + } + $: classesSidebarOpen = (open: boolean) => (open ? 'ml-64' : 'ml-7'); @@ -22,7 +50,13 @@ - {$pageTitle} + + {#if items[$pageTitle]} + {items[$pageTitle]} + {:else} + {$pageTitle} + {/if} +
    From 3317c79df7b40ebae115be01d216ec4648fc52c9 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Tue, 13 Feb 2024 16:13:46 +0100 Subject: [PATCH 04/19] feat: translate sidebar footer options --- frontend/messages/en.json | 7 ++++++- frontend/messages/fr.json | 7 ++++++- .../src/lib/components/SideBar/SideBarFooter.svelte | 13 +++++++++---- frontend/src/lib/utils/locales.ts | 4 ++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 49e03b9e1..b3aa90952 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1,5 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", + "french": "French", + "english": "English", "home": "Home", "edit": "Edit", "overview": "Overview", @@ -31,5 +33,8 @@ "xRays": "X-rays", "scoringAssistant": "Scoring assistant", "libraries": "Libraries", - "backupRestore": "Backup & restore" + "backupRestore": "Backup & restore", + "myProfile": "My profile", + "aboutCiso": "About CISO Assistant", + "Logout": "Log out" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index e84cffae9..ae1c15fe2 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1,5 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", + "french": "Français", + "english": "Anglais", "home": "Accueil", "edit": "Modifier", "overview": "Vue d'ensemble", @@ -31,5 +33,8 @@ "xRays": "X-rays", "scoringAssistant": "Assistat d'évaluation", "libraries": "Bibliothèques", - "backupRestore": "Sauvegarde et restauration" + "backupRestore": "Sauvegarde et restauration", + "myProfile": "Mon profil", + "aboutCiso": "À propos de CISO Assistant", + "Logout": "Se déconnecter" } diff --git a/frontend/src/lib/components/SideBar/SideBarFooter.svelte b/frontend/src/lib/components/SideBar/SideBarFooter.svelte index c65d48b56..3f32995d0 100644 --- a/frontend/src/lib/components/SideBar/SideBarFooter.svelte +++ b/frontend/src/lib/components/SideBar/SideBarFooter.svelte @@ -7,6 +7,11 @@ import { LOCALE_MAP } from '$lib/utils/locales'; import * as m from '$paraglide/messages'; + const language: any = { + french: m.french(), + english: m.english() + } + const modalStore = getModalStore(); let value = languageTag(); @@ -63,7 +68,7 @@ My profile{m.myProfile()} @@ -80,13 +85,13 @@ on:click={modalBuildInfo} class="cursor-pointer flex items-center gap-2 w-full px-4 py-2.5 text-left text-sm hover:bg-gray-100 disabled:text-gray-500 text-gray-800" data-testid="about-button" - >About CISO Assistant{m.aboutCiso()}
    diff --git a/frontend/src/lib/utils/locales.ts b/frontend/src/lib/utils/locales.ts index 3ad4abccc..a79453eec 100644 --- a/frontend/src/lib/utils/locales.ts +++ b/frontend/src/lib/utils/locales.ts @@ -1,10 +1,10 @@ export const LOCALE_MAP = { en: { - name: 'English', + name: 'english', flag: '🇬🇧' }, fr: { - name: 'French', + name: 'french', flag: '🇫🇷' } }; From 581765baecda79c428dbc2c65cef62e9497fe847 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 14 Feb 2024 16:48:31 +0100 Subject: [PATCH 05/19] feat: add english ref for modeltables --- frontend/messages/en.json | 26 +++++++++- frontend/messages/fr.json | 3 +- .../components/ModelTable/ModelTable.svelte | 32 +++++++++++- frontend/src/lib/utils/table.ts | 52 +++++++++---------- 4 files changed, 84 insertions(+), 29 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index b3aa90952..02213c207 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -36,5 +36,29 @@ "backupRestore": "Backup & restore", "myProfile": "My profile", "aboutCiso": "About CISO Assistant", - "Logout": "Log out" + "Logout": "Log out", + "name": "name", + "description": "Description", + "parentDomain": "Domaine parent", + "ref": "Réf", + "refId": "ID de référence", + "businessValue": "Valeur commerciale", + "email": "Email", + "firstName": "Prénom", + "lastName": "Nom", + "category": "Catégorie", + "eta": "ETA", + "securityFunction": "Fonction de sécurité", + "provider": "Fournisseur", + "domain": "Domaine", + "urn": "URN", + "id": "ID", + "treatmentStatus": "État du traitement", + "currentLevel": "Niveau actuel", + "residualLevel": "Niveau résiduel", + "riskMatrix": "Matrice de risques", + "project": "Projet", + "folder": "Dossier", + "meta": "Méta", + "builtin": "Intégré" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index ae1c15fe2..def48fcde 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -36,5 +36,6 @@ "backupRestore": "Sauvegarde et restauration", "myProfile": "Mon profil", "aboutCiso": "À propos de CISO Assistant", - "Logout": "Se déconnecter" + "Logout": "Se déconnecter", + "name": "nom" } diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 198d8f424..4e0659f3a 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -11,6 +11,7 @@ import type { SuperValidated } from 'sveltekit-superforms'; import type { AnyZodObject } from 'zod'; import type { TableSource } from './types'; + import * as m from '$paraglide/messages'; // Event Dispatcher type TableEvent = { selected: string[]; @@ -119,6 +120,35 @@ // 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(), + meta: m.meta(), + builtin: m.builtin(), + }
    @@ -145,7 +175,7 @@ {#each Object.entries(source.head) as [key, heading]} - {heading} + {headTranslate[heading]} {/each} {#if displayActions} diff --git a/frontend/src/lib/utils/table.ts b/frontend/src/lib/utils/table.ts index f1ccf135d..89d9966e2 100644 --- a/frontend/src/lib/utils/table.ts +++ b/frontend/src/lib/utils/table.ts @@ -1,35 +1,35 @@ export const listViewFields = { folders: { - head: ['name', 'description', 'parent domain'], + head: ['name', 'description', 'parentDomain'], body: ['name', 'description', 'parent_folder'] }, projects: { - head: ['Name', 'Description', 'Domain'], + head: ['name', 'description', 'domain'], body: ['name', 'description', 'folder'] }, 'risk-matrices': { - head: ['Name', 'Description', 'Provider', 'Domain'], + head: ['name', 'description', 'provider', 'domain'], body: ['name', 'description', 'provider', 'folder'], meta: ['id', 'urn'] }, 'risk-assessments': { - head: ['Name', 'Risk matrix', 'Description', 'Risk Scenarios', 'Project'], + head: ['name', 'riskMatrix', 'description', 'riskScenarios', 'project'], body: ['name', 'risk_matrix', 'description', 'risk_scenarios', 'project'] }, threats: { - head: ['Ref', 'Name', 'Description', 'Provider', 'Domain'], + head: ['ref', 'name', 'description', 'provider', 'domain'], body: ['ref_id', 'name', 'description', 'provider', 'folder'], meta: ['id', 'urn'] }, 'risk-scenarios': { head: [ - 'Name', - 'Treatment status', - 'Threat', - 'Risk assessment', - 'Assets', - 'Current level', - 'Residual level' + 'name', + 'treatmentStatus', + 'threat', + 'riskAssessment', + 'assets', + 'currentLevel', + 'residualLevel' ], body: [ 'name', @@ -42,63 +42,63 @@ export const listViewFields = { ] }, 'risk-acceptances': { - head: ['Name', 'Description', 'Risk scenarios'], + head: ['name', 'description', 'riskScenarios'], body: ['name', 'description', 'risk_scenarios'] }, 'security-measures': { - head: ['Name', 'Description', 'Category', 'ETA', 'Domain', 'Security function'], + head: ['name', 'description', 'category', 'eta', 'domain', 'securityFunction'], body: ['name', 'description', 'category', 'eta', 'folder', 'security_function'] }, 'security-functions': { - head: ['Ref', 'Name', 'Description', 'Category', 'Provider', 'Domain'], + head: ['ref', 'name', 'description', 'category', 'provider', 'domain'], body: ['ref_id', 'name', 'description', 'category', 'provider', 'folder'], meta: ['id', 'urn'] }, assets: { - head: ['Name', 'Description', 'Business value', 'Domain'], + head: ['name', 'description', 'businessValue', 'domain'], body: ['name', 'description', 'business_value', 'folder'] }, users: { - head: ['Email', 'First name', 'Last name'], + head: ['email', 'firstName', 'lastName'], body: ['email', 'first_name', 'last_name'] }, 'user-groups': { - head: ['Name'], + head: ['name'], body: ['name'], meta: ['id', 'builtin'] }, roles: { - head: ['Name', 'Description'], + head: ['name', 'description'], body: ['name', 'description'] }, 'role-assignments': { - head: ['User', 'User group', 'Role', 'Perimeter'], + head: ['user', 'userGroup', 'role', 'perimeter'], body: ['user', 'user_group', 'role', 'perimeter_folders'] }, frameworks: { - head: ['Name', 'Description', 'Provider', 'Compliance assessments', 'Domain'], + head: ['name', 'description', 'provider', 'complianceAssessments', 'domain'], body: ['name', 'description', 'provider', 'compliance_assessments', 'folder'], meta: ['id', 'urn'] }, 'compliance-assessments': { - head: ['Name', 'Framework', 'Description', 'Project'], + head: ['name', 'framework', 'description', 'project'], body: ['name', 'framework', 'description', 'project'] }, 'requirement-assessments': { - head: ['Name', 'Description', 'Compliance Assessment'], + head: ['name', 'description', 'complianceAssessment'], body: ['name', 'description', 'compliance_assessment'] }, evidences: { - head: ['Name', 'File', 'Description'], + head: ['name', 'file', 'description'], body: ['name', 'attachment', 'description'] }, requirements: { - head: ['Ref', 'Name', 'Description', 'Framework'], + head: ['ref', 'name', 'description', 'framework'], body: ['ref_id', 'name', 'description', 'framework'], meta: ['id', 'urn'] }, libraries: { - head: ['Ref', 'Name', 'Description', 'Language', 'Overview'], + head: ['ref', 'name', 'description', 'language', 'overview'], body: ['ref_id', 'name', 'description', 'locale', 'overview'] } }; From c42c59ef5edb1835549fd2a2528337955aaa190b Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 14 Feb 2024 16:52:56 +0100 Subject: [PATCH 06/19] fix: translations errors --- frontend/messages/en.json | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 02213c207..45c63f8d6 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -39,26 +39,26 @@ "Logout": "Log out", "name": "name", "description": "Description", - "parentDomain": "Domaine parent", - "ref": "Réf", - "refId": "ID de référence", - "businessValue": "Valeur commerciale", - "email": "Email", - "firstName": "Prénom", - "lastName": "Nom", - "category": "Catégorie", - "eta": "ETA", - "securityFunction": "Fonction de sécurité", - "provider": "Fournisseur", - "domain": "Domaine", - "urn": "URN", - "id": "ID", - "treatmentStatus": "État du traitement", - "currentLevel": "Niveau actuel", - "residualLevel": "Niveau résiduel", - "riskMatrix": "Matrice de risques", - "project": "Projet", - "folder": "Dossier", - "meta": "Méta", - "builtin": "Intégré" + "parentDomain": "Parent domain", + "ref": "Ref", + "refId": "Ref ID", + "businessValue": "Business value", + "email": "Email", + "firstName": "First name", + "lastName": "Last name", + "category": "Category", + "eta": "ETA", + "securityFunction": "Security function", + "provider": "Provider", + "domain": "Domain", + "urn": "URN", + "id": "ID", + "treatmentStatus": "Treatment status", + "currentLevel": "Current level", + "residualLevel": "Residual level", + "riskMatrix": "Risk matrix", + "project": "Project", + "folder": "Folder", + "meta": "Meta", + "builtin": "Builtin" } From b7377be19210c633d34f2f37cbe73254b392824d Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene <90701924+Mohamed-Hacene@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:54:36 +0100 Subject: [PATCH 07/19] inlang: update translations --- frontend/messages/fr.json | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index def48fcde..ee5f62fed 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -37,5 +37,28 @@ "myProfile": "Mon profil", "aboutCiso": "À propos de CISO Assistant", "Logout": "Se déconnecter", - "name": "nom" + "name": "nom", + "description": "Description", + "parentDomain": "Domaine parent", + "ref": "Réf", + "refId": "ID de référence", + "businessValue": "Valeur commerciale", + "email": "E-mail", + "firstName": "Prénom", + "lastName": "Nom de famille", + "category": "Catégorie", + "eta": "ETA", + "securityFunction": "Fonction de sécurité", + "provider": "Fournisseur", + "domain": "Domaine", + "urn": "URN", + "id": "ID", + "treatmentStatus": "Statut de traitement", + "currentLevel": "Niveau actuel", + "residualLevel": "Niveau résiduel", + "riskMatrix": "Matrice des risques", + "project": "Projet", + "folder": "Dossier", + "meta": "Méta", + "builtin": "Intégré" } From 7522937a6825ebdad2beab99757e9b6e4372eec8 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 14 Feb 2024 16:55:11 +0100 Subject: [PATCH 08/19] chore: remove useless word meta --- frontend/messages/en.json | 1 - frontend/messages/fr.json | 1 - 2 files changed, 2 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 45c63f8d6..94e21fda0 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -59,6 +59,5 @@ "riskMatrix": "Risk matrix", "project": "Project", "folder": "Folder", - "meta": "Meta", "builtin": "Builtin" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index ee5f62fed..e65016446 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -59,6 +59,5 @@ "riskMatrix": "Matrice des risques", "project": "Projet", "folder": "Dossier", - "meta": "Méta", "builtin": "Intégré" } From 57479ffba2aa3cc1550701fe4a86d2c62ecede36 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 14 Feb 2024 17:03:13 +0100 Subject: [PATCH 09/19] feat: add missing tables columns name --- frontend/messages/en.json | 5 +++++ frontend/messages/fr.json | 5 +++++ frontend/src/lib/components/ModelTable/ModelTable.svelte | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 94e21fda0..29b6f6fda 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -59,5 +59,10 @@ "riskMatrix": "Risk matrix", "project": "Project", "folder": "Folder", + "riskAssessment": "Risk assessment", + "threat": "Threat", + "framework": "Framework", + "file": "File", + "language": "Language", "builtin": "Builtin" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index e65016446..4ff7910fe 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -59,5 +59,10 @@ "riskMatrix": "Matrice des risques", "project": "Projet", "folder": "Dossier", + "riskAssessment": "Évaluation de risque", + "threat": "Menace", + "framework": "Cadre", + "file": "Fichier", + "language": "Langue", "builtin": "Intégré" } diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 4e0659f3a..ec9e91e10 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -146,8 +146,14 @@ project: m.project(), complianceAssessments: m.complianceAssessments(), folder: m.folder(), - meta: m.meta(), builtin: m.builtin(), + assets: m.assets(), + threat: m.threat(), + riskAssessment: m.riskAssessment(), + framework: m.framework(), + file: m.file(), + overview: m.overview(), + language: m.language() } From 4a9030f13e76459a36ba53cb77d6bc0a0a214ef5 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 15 Feb 2024 12:43:00 +0100 Subject: [PATCH 10/19] feat: optimize tranlsation --- .../components/Breadcrumbs/Breadcrumbs.svelte | 41 ++-------- .../components/SideBar/SideBarCategory.svelte | 15 +--- .../lib/components/SideBar/SideBarItem.svelte | 31 +------- frontend/src/lib/utils/locales.ts | 78 +++++++++++++++++++ .../(app)/[model=urlmodel]/+page.svelte | 2 + 5 files changed, 94 insertions(+), 73 deletions(-) diff --git a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte index 1805fe609..6c72faf1d 100644 --- a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte +++ b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte @@ -1,35 +1,10 @@ - {sidebar[item.name]} + {localItems(languageTag())[item.name]} diff --git a/frontend/src/lib/components/SideBar/SideBarItem.svelte b/frontend/src/lib/components/SideBar/SideBarItem.svelte index 150ccb2ae..fb3bfd3d5 100644 --- a/frontend/src/lib/components/SideBar/SideBarItem.svelte +++ b/frontend/src/lib/components/SideBar/SideBarItem.svelte @@ -1,38 +1,13 @@ {#each item as item} @@ -45,7 +20,7 @@ > - {items[item.name]} + {localItems(languageTag())[item.name]} {/each} diff --git a/frontend/src/lib/utils/locales.ts b/frontend/src/lib/utils/locales.ts index a79453eec..7bb796fe3 100644 --- a/frontend/src/lib/utils/locales.ts +++ b/frontend/src/lib/utils/locales.ts @@ -1,3 +1,5 @@ +import * as m from '$paraglide/messages'; + export const LOCALE_MAP = { en: { name: 'english', @@ -8,3 +10,79 @@ export const LOCALE_MAP = { flag: '🇫🇷' } }; + +interface LocalItems { + [key: string]: string; +}; + + +export function localItems(languageTag: string): LocalItems { + const LOCAL_ITEMS = { + french: m.french({ languageTag: languageTag }), + english: m.english({ languageTag: languageTag }), + home: m.home({ languageTag: languageTag }), + edit: m.edit({ languageTag: languageTag }), + overview: m.overview({ languageTag: languageTag }), + context: m.context({ languageTag: languageTag }), + governance: m.governance({ languageTag: languageTag }), + risk: m.risk({ languageTag: languageTag }), + compliance: m.compliance({ languageTag: languageTag }), + organisation: m.organisation({ languageTag: languageTag }), + extra: m.extra({ languageTag: languageTag }), + analytics: m.analytics({ languageTag: languageTag }), + calendar: m.calendar({ languageTag: languageTag }), + threats: m.threats({ languageTag: languageTag }), + securityFunctions: m.securityFunctions({ languageTag: languageTag }), + securityMeasures: m.securityMeasures({ languageTag: languageTag }), + assets: m.assets({ languageTag: languageTag }), + policies: m.policies({ languageTag: languageTag }), + riskMatrices: m.riskMatrices({ languageTag: languageTag }), + riskAssessments: m.riskAssessments({ languageTag: languageTag }), + riskScenarios: m.riskScenarios({ languageTag: languageTag }), + riskAcceptances: m.riskAcceptances({ languageTag: languageTag }), + complianceAssessments: m.complianceAssessments({ languageTag: languageTag }), + evidences: m.evidences({ languageTag: languageTag }), + frameworks: m.frameworks({ languageTag: languageTag }), + domains: m.domains({ languageTag: languageTag }), + projects: m.projects({ languageTag: languageTag }), + users: m.users({ languageTag: languageTag }), + userGroups: m.userGroups({ languageTag: languageTag }), + roleAssignments: m.roleAssignments({ languageTag: languageTag }), + xRays: m.xRays({ languageTag: languageTag }), + scoringAssistant: m.scoringAssistant({ languageTag: languageTag }), + libraries: m.libraries({ languageTag: languageTag }), + backupRestore: m.backupRestore({ languageTag: languageTag }), + myProfile: m.myProfile({ languageTag: languageTag }), + aboutCiso: m.aboutCiso({ languageTag: languageTag }), + Logout: m.Logout({ languageTag: languageTag }), + name: m.name({ languageTag: languageTag }), + description: m.description({ languageTag: languageTag }), + parentDomain: m.parentDomain({ languageTag: languageTag }), + ref: m.ref({ languageTag: languageTag }), + refId: m.refId({ languageTag: languageTag }), + businessValue: m.businessValue({ languageTag: languageTag }), + email: m.email({ languageTag: languageTag }), + firstName: m.firstName({ languageTag: languageTag }), + lastName: m.lastName({ languageTag: languageTag }), + category: m.category({ languageTag: languageTag }), + eta: m.eta({ languageTag: languageTag }), + securityFunction: m.securityFunction({ languageTag: languageTag }), + provider: m.provider({ languageTag: languageTag }), + domain: m.domain({ languageTag: languageTag }), + urn: m.urn({ languageTag: languageTag }), + id: m.id({ languageTag: languageTag }), + treatmentStatus: m.treatmentStatus({ languageTag: languageTag }), + currentLevel: m.currentLevel({ languageTag: languageTag }), + residualLevel: m.residualLevel({ languageTag: languageTag }), + riskMatrix: m.riskMatrix({ languageTag: languageTag }), + project: m.project({ languageTag: languageTag }), + folder: m.folder({ languageTag: languageTag }), + riskAssessment: m.riskAssessment({ languageTag: languageTag }), + threat: m.threat({ languageTag: languageTag }), + framework: m.framework({ languageTag: languageTag }), + file: m.file({ languageTag: languageTag }), + language: m.language({ languageTag: languageTag }), + builtin: m.builtin({ languageTag: languageTag }), + }; + return LOCAL_ITEMS; +} \ No newline at end of file diff --git a/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte b/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte index d84b8db92..803629e2f 100644 --- a/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte +++ b/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte @@ -11,6 +11,8 @@ import { getModalStore, getToastStore } from '@skeletonlabs/skeleton'; import { superForm } from 'sveltekit-superforms/client'; import type { PageData } from './$types'; + import { localItems } from '$lib/utils/locales'; + import { languageTag } from '$paraglide/runtime'; export let data: PageData; From af524383b396192ee5b580f87d1470251f40879b Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 15 Feb 2024 14:00:25 +0100 Subject: [PATCH 11/19] feat: create 1st version of determinants table --- frontend/messages/en.json | 8 + frontend/messages/fr.json | 8 + frontend/src/lib/utils/crud.ts | 418 ++++++++++-------- frontend/src/lib/utils/locales.ts | 32 ++ .../(app)/[model=urlmodel]/+page.svelte | 7 +- 5 files changed, 280 insertions(+), 193 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 29b6f6fda..582432be7 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1,5 +1,6 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", + "addButton": "Add {model}", "french": "French", "english": "English", "home": "Home", @@ -17,17 +18,23 @@ "securityFunctions": "Security functions", "securityMeasures": "Security measures", "assets": "Assets", + "asset": "Asset", "policies": "Policies", "riskMatrices": "Risk matrices", "riskAssessments": "Risk assessments", "riskScenarios": "Risk scenarios", + "riskScenario": "Risk scenario", "riskAcceptances": "Risk acceptances", + "riskAcceptance": "Risk acceptance", "complianceAssessments": "Compliance assessments", + "complianceAssessment": "Compliance assessment", "evidences": "Evidences", + "evidence": "Evidence", "frameworks": "Frameworks", "domains": "Domains", "projects": "Projects", "users": "Users", + "user": "User", "userGroups": "User groups", "roleAssignments": "Role assignments", "xRays": "X-rays", @@ -49,6 +56,7 @@ "category": "Category", "eta": "ETA", "securityFunction": "Security function", + "securityMeasure": "Security measure", "provider": "Provider", "domain": "Domain", "urn": "URN", diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 4ff7910fe..ae29e7d01 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1,5 +1,6 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", + "addButton": "Ajouter {determinant} {model}", "french": "Français", "english": "Anglais", "home": "Accueil", @@ -17,17 +18,23 @@ "securityFunctions": "Fonctions de sécurité", "securityMeasures": "Mesures de sécurité", "assets": "Biens sensibles", + "asset": "Bien sensible", "policies": "Politiques", "riskMatrices": "Matrices de risque", "riskAssessments": "Évaluations de risque", "riskScenarios": "Scénarios de risque", + "riskScenario": "Scénario de risque", "riskAcceptances": "Acceptations de risque", + "riskAcceptance": "Acceptation de risque", "complianceAssessments": "Évaluations de conformité", + "complianceAssessment": "Évaluation de conformité", "evidences": "Preuves", + "evidence": "Preuve", "frameworks": "Cadres", "domains": "Domaines", "projects": "Projets", "users": "Utilisateurs", + "user": "Utilisateur", "userGroups": "Groupes d'utilisateurs", "roleAssignments": "Affectations de rôle", "xRays": "X-rays", @@ -49,6 +56,7 @@ "category": "Catégorie", "eta": "ETA", "securityFunction": "Fonction de sécurité", + "securityMeasure": "Mesure de sécurité", "provider": "Fournisseur", "domain": "Domaine", "urn": "URN", diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index eef2cf201..3fddd4cc1 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -88,197 +88,233 @@ type ModelMap = { export const URL_MODEL_MAP: ModelMap = { folders: { - name: 'folder', - verboseName: 'Domain', - verboseNamePlural: 'Domains', - // NOTE: urlParams hard-coded for now, but should be dynamic - foreignKeyFields: [ - { field: 'parent_folder', urlModel: 'folders', urlParams: 'content_type=GL' } - ], - reverseForeignKeyFields: [{ field: 'folder', urlModel: 'projects' }] - }, - projects: { - name: 'project', - verboseName: 'Project', - verboseNamePlural: 'Projects', - // NOTE: urlParams hard-coded for now, but should be dynamic - foreignKeyFields: [{ field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO' }], - selectFields: [{ field: 'lc_status' }], - reverseForeignKeyFields: [ - { field: 'project', urlModel: 'risk-assessments' }, - { field: 'project', urlModel: 'compliance-assessments' } - ], - filters: [{ field: 'lc_status' }, { field: 'folder' }] - }, - 'risk-matrices': { - name: 'riskmatrix', - verboseName: 'Risk matrix', - verboseNamePlural: 'Risk matrices', - foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }] - }, - 'risk-assessments': { - name: 'riskassessment', - verboseName: 'Risk assessment', - verboseNamePlural: 'Risk assessments', - foreignKeyFields: [ - { field: 'project', urlModel: 'projects' }, - { field: 'auditor', urlModel: 'users' }, - { field: 'risk_matrix', urlModel: 'risk-matrices' }, - { field: 'risk_scenarios', urlModel: 'risk-scenarios' } - ], - reverseForeignKeyFields: [{ field: 'risk_assessment', urlModel: 'risk-scenarios' }], - filters: [{ field: 'project' }, { field: 'auditor' }] - }, - threats: { - ref_id: 'ref_id', - name: 'threat', - verboseName: 'Threat', - verboseNamePlural: 'Threats', - foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }] - }, - 'risk-scenarios': { - name: 'riskscenario', - verboseName: 'Risk scenario', - verboseNamePlural: 'Risk scenarios', - foreignKeyFields: [ - { field: 'threats', urlModel: 'threats' }, - { field: 'risk_assessment', urlModel: 'risk-assessments' }, - { field: 'assets', urlModel: 'assets' }, - { field: 'security_measures', urlModel: 'security-measures' }, - { field: 'project', urlModel: 'projects' }, - { field: 'risk_matrix', urlModel: 'risk-matrices' }, - { field: 'auditor', urlModel: 'users' } - ], - filters: [{ field: 'threats' }, { field: 'risk_assessment' }], - search: false - }, - 'security-measures': { - name: 'securitymeasure', - verboseName: 'Security measure', - verboseNamePlural: 'Security measures', - foreignKeyFields: [ - { field: 'security_function', urlModel: 'security-functions' }, - { field: 'folder', urlModel: 'folders' }, - { field: 'evidences', urlModel: 'evidences' } - ], - selectFields: [{ field: 'status' }, { field: 'category' }, { field: 'effort' }], - filters: [ - { field: 'security_function' }, - { field: 'status' }, - { field: 'category' }, - { field: 'effort' }, - { field: 'folder' } - ] - }, - 'risk-acceptances': { - name: 'riskacceptance', - verboseName: 'Risk acceptance', - verboseNamePlural: 'Risk acceptances', - foreignKeyFields: [ - { - field: 'risk_scenarios', - urlModel: 'risk-scenarios', - urlParams: '/acceptable' - }, - { field: 'folder', urlModel: 'folders' }, - { field: 'approver', urlModel: 'users', urlParams: 'is_approver=true' } - ], - filters: [{ field: 'risk_scenarios' }, { field: 'folder' }, { field: 'approver' }] - }, - 'security-functions': { - ref_id: 'ref_id', - name: 'securityfunction', - verboseName: 'Security function', - verboseNamePlural: 'Security functions', - foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }], - selectFields: [{ field: 'category' }], - filters: [{ field: 'folder' }] - }, - assets: { - name: 'asset', - verboseName: 'Asset', - verboseNamePlural: 'Assets', - foreignKeyFields: [ - { field: 'parent_assets', urlModel: 'assets' }, - { field: 'folder', urlModel: 'folders' } - ], - selectFields: [{ field: 'type' }], - filters: [{ field: 'parent_assets' }, { field: 'folder' }, { field: 'type' }] - }, - users: { - name: 'user', - verboseName: 'User', - verboseNamePlural: 'Users', - foreignKeyFields: [{ field: 'user_groups', urlModel: 'user-groups' }], - filters: [] - }, - 'user-groups': { - name: 'usergroup', - verboseName: 'User group', - verboseNamePlural: 'User groups', - foreignKeyFields: [], - filters: [] - }, - 'role-assignments': { - name: 'roleassignment', - verboseName: 'Role assignment', - verboseNamePlural: 'Role assignments', - foreignKeyFields: [], - filters: [] - }, - frameworks: { - ref_id: 'ref_id', - name: 'framework', - verboseName: 'Framework', - verboseNamePlural: 'Frameworks', - foreignKeyFields: [ - { - field: 'folder', - urlModel: 'folders' - } - ] - }, - evidences: { - name: 'evidence', - verboseName: 'Evidence', - verboseNamePlural: 'Evidences', - foreignKeyFields: [ - { field: 'folder', urlModel: 'folders' }, - { field: 'security_measures', urlModel: 'security-measures' }, - { field: 'requirement_assessments', urlModel: 'requirement-assessments' } - ] - }, - 'compliance-assessments': { - name: 'complianceassessment', - verboseName: 'Compliance assessment', - verboseNamePlural: 'Compliance assessments', - foreignKeyFields: [ - { field: 'project', urlModel: 'projects' }, - { field: 'framework', urlModel: 'frameworks' } - ] - }, - requirements: { - ref_id: 'ref_id', - name: 'requirement', - verboseName: 'Requirement', - verboseNamePlural: 'Requirements' - }, - 'requirement-assessments': { - name: 'requirementassessment', - verboseName: 'Requirement assessment', - verboseNamePlural: 'Requirement assessments', - selectFields: [{ field: 'status' }], - foreignKeyFields: [ - { field: 'security_measures', urlModel: 'security-measures' }, - { field: 'evidences', urlModel: 'evidences' }, - { field: 'compliance_assessment', urlModel: 'compliance-assessments' } - ] - }, - libraries: { - name: 'library', - verboseName: 'Library', - verboseNamePlural: 'Libraries' - } + name: 'folder', + localName: 'domain', + localFrGender: 'm', + verboseName: 'Domain', + verboseNamePlural: 'Domains', + foreignKeyFields: [ + { field: 'parent_folder', urlModel: 'folders', urlParams: 'content_type=GL' } + ], + reverseForeignKeyFields: [{ field: 'folder', urlModel: 'projects' }] + }, + projects: { + name: 'project', + localName: 'project', + localFrGender: 'm', + verboseName: 'Project', + verboseNamePlural: 'Projects', + foreignKeyFields: [{ field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO' }], + selectFields: [{ field: 'lc_status' }], + reverseForeignKeyFields: [ + { field: 'project', urlModel: 'risk-assessments' }, + { field: 'project', urlModel: 'compliance-assessments' } + ], + filters: [{ field: 'lc_status' }, { field: 'folder' }] + }, + 'risk-matrices': { + name: 'riskmatrix', + localName: 'riskMatrix', + localFrGender: 'f', + verboseName: 'Risk matrix', + verboseNamePlural: 'Risk matrices', + foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }] + }, + 'risk-assessments': { + name: 'riskassessment', + localName: 'riskAssessment', + localFrGender: 'f', + verboseName: 'Risk assessment', + verboseNamePlural: 'Risk assessments', + foreignKeyFields: [ + { field: 'project', urlModel: 'projects' }, + { field: 'auditor', urlModel: 'users' }, + { field: 'risk_matrix', urlModel: 'risk-matrices' }, + { field: 'risk_scenarios', urlModel: 'risk-scenarios' } + ], + reverseForeignKeyFields: [{ field: 'risk_assessment', urlModel: 'risk-scenarios' }], + filters: [{ field: 'project' }, { field: 'auditor' }] + }, + threats: { + ref_id: 'ref_id', + name: 'threat', + localName: 'threat', + localFrGender: 'f', + verboseName: 'Threat', + verboseNamePlural: 'Threats', + foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }] + }, + 'risk-scenarios': { + name: 'riskscenario', + localName: 'riskScenario', + localFrGender: 'm', + verboseName: 'Risk scenario', + verboseNamePlural: 'Risk scenarios', + foreignKeyFields: [ + { field: 'threats', urlModel: 'threats' }, + { field: 'risk_assessment', urlModel: 'risk-assessments' }, + { field: 'assets', urlModel: 'assets' }, + { field: 'security_measures', urlModel: 'security-measures' }, + { field: 'project', urlModel: 'projects' }, + { field: 'risk_matrix', urlModel: 'risk-matrices' }, + { field: 'auditor', urlModel: 'users' } + ], + filters: [{ field: 'threats' }, { field: 'risk_assessment' }], + search: false + }, + 'security-measures': { + name: 'securitymeasure', + localName: 'securityMeasure', + localFrGender: 'f', + verboseName: 'Security measure', + verboseNamePlural: 'Security measures', + foreignKeyFields: [ + { field: 'security_function', urlModel: 'security-functions' }, + { field: 'folder', urlModel: 'folders' }, + { field: 'evidences', urlModel: 'evidences' } + ], + selectFields: [{ field: 'status' }, { field: 'category' }, { field: 'effort' }], + filters: [ + { field: 'security_function' }, + { field: 'status' }, + { field: 'category' }, + { field: 'effort' }, + { field: 'folder' } + ] + }, + 'risk-acceptances': { + name: 'riskacceptance', + localName: 'riskAcceptance', + localFrGender: 'f', + verboseName: 'Risk acceptance', + verboseNamePlural: 'Risk acceptances', + foreignKeyFields: [ + { + field: 'risk_scenarios', + urlModel: 'risk-scenarios', + urlParams: '/acceptable' + }, + { field: 'folder', urlModel: 'folders' }, + { field: 'approver', urlModel: 'users', urlParams: 'is_approver=true' } + ], + filters: [{ field: 'risk_scenarios' }, { field: 'folder' }, { field: 'approver' }] + }, + 'security-functions': { + ref_id: 'ref_id', + name: 'securityfunction', + localName: 'securityFunction', + localFrGender: 'f', + verboseName: 'Security function', + verboseNamePlural: 'Security functions', + foreignKeyFields: [{ field: 'folder', urlModel: 'folders' }], + selectFields: [{ field: 'category' }], + filters: [{ field: 'folder' }] + }, + assets: { + name: 'asset', + localName: 'asset', + localFrGender: 'm', + verboseName: 'Asset', + verboseNamePlural: 'Assets', + foreignKeyFields: [ + { field: 'parent_assets', urlModel: 'assets' }, + { field: 'folder', urlModel: 'folders' } + ], + selectFields: [{ field: 'type' }], + filters: [{ field: 'parent_assets' }, { field: 'folder' }, { field: 'type' }] + }, + users: { + name: 'user', + localName: 'user', + localFrGender: 'm', + verboseName: 'User', + verboseNamePlural: 'Users', + foreignKeyFields: [{ field: 'user_groups', urlModel: 'user-groups' }], + filters: [] + }, + 'user-groups': { + name: 'usergroup', + localName: 'userGroup', + localFrGender: 'm', + verboseName: 'User group', + verboseNamePlural: 'User groups', + foreignKeyFields: [], + filters: [] + }, + 'role-assignments': { + name: 'roleassignment', + localName: 'roleAssignment', + localFrGender: 'f', + verboseName: 'Role assignment', + verboseNamePlural: 'Role assignments', + foreignKeyFields: [], + filters: [] + }, + frameworks: { + ref_id: 'ref_id', + name: 'framework', + localName: 'framework', + localFrGender: 'm', + verboseName: 'Framework', + verboseNamePlural: 'Frameworks', + foreignKeyFields: [ + { + field: 'folder', + urlModel: 'folders' + } + ] + }, + evidences: { + name: 'evidence', + localName: 'evidence', + localFrGender: 'f', + verboseName: 'Evidence', + verboseNamePlural: 'Evidences', + foreignKeyFields: [ + { field: 'folder', urlModel: 'folders' }, + { field: 'security_measures', urlModel: 'security-measures' }, + { field: 'requirement_assessments', urlModel: 'requirement-assessments' } + ] + }, + 'compliance-assessments': { + name: 'complianceassessment', + localName: 'complianceAssessment', + localFrGender: 'f', + verboseName: 'Compliance assessment', + verboseNamePlural: 'Compliance assessments', + foreignKeyFields: [ + { field: 'project', urlModel: 'projects' }, + { field: 'framework', urlModel: 'frameworks' } + ] + }, + requirements: { + ref_id: 'ref_id', + name: 'requirement', + localName: 'requirement', + localFrGender: 'f', + verboseName: 'Requirement', + verboseNamePlural: 'Requirements' + }, + 'requirement-assessments': { + name: 'requirementassessment', + localName: 'requirementAssessment', + localFrGender: 'f', + verboseName: 'Requirement assessment', + verboseNamePlural: 'Requirement assessments', + selectFields: [{ field: 'status' }], + foreignKeyFields: [ + { field: 'security_measures', urlModel: 'security-measures' }, + { field: 'evidences', urlModel: 'evidences' }, + { field: 'compliance_assessment', urlModel: 'compliance-assessments' } + ] + }, + libraries: { + name: 'library', + localName: 'library', + localFrGender: 'f', + verboseName: 'Library', + verboseNamePlural: 'Libraries' + } }; export const FIELD_COMPONENT_MAP = { diff --git a/frontend/src/lib/utils/locales.ts b/frontend/src/lib/utils/locales.ts index 7bb796fe3..4c8cf2e69 100644 --- a/frontend/src/lib/utils/locales.ts +++ b/frontend/src/lib/utils/locales.ts @@ -1,4 +1,5 @@ import * as m from '$paraglide/messages'; +import type { ModelInfo } from '$lib/utils/types'; export const LOCALE_MAP = { en: { @@ -11,6 +12,30 @@ export const LOCALE_MAP = { } }; +export function getDeterminant(lang: string, defined: string, model: ModelInfo, plural=false): string { + const determinantTable = { + "fr": { + "defined": { + "plural": "les", + "m": "le", + "f": "la" + }, + "undefined": { + "plural": "des", + "m": "un", + "f": "une" + } + } + }; + + if (lang === "en") + return ''; + else if (lang === "fr" && plural) + return determinantTable[lang][defined]["plural"]; + else + return determinantTable[lang][defined][model.localFrGender]; +} + interface LocalItems { [key: string]: string; }; @@ -35,17 +60,23 @@ export function localItems(languageTag: string): LocalItems { securityFunctions: m.securityFunctions({ languageTag: languageTag }), securityMeasures: m.securityMeasures({ languageTag: languageTag }), assets: m.assets({ languageTag: languageTag }), + asset: m.asset({ languageTag: languageTag }), policies: m.policies({ languageTag: languageTag }), riskMatrices: m.riskMatrices({ languageTag: languageTag }), riskAssessments: m.riskAssessments({ languageTag: languageTag }), riskScenarios: m.riskScenarios({ languageTag: languageTag }), + riskScenario: m.riskScenario({ languageTag: languageTag }), riskAcceptances: m.riskAcceptances({ languageTag: languageTag }), + riskAcceptance: m.riskAcceptance({ languageTag: languageTag }), complianceAssessments: m.complianceAssessments({ languageTag: languageTag }), + complianceAssessment: m.complianceAssessment({ languageTag: languageTag }), evidences: m.evidences({ languageTag: languageTag }), + evidence: m.evidence({ languageTag: languageTag }), frameworks: m.frameworks({ languageTag: languageTag }), domains: m.domains({ languageTag: languageTag }), projects: m.projects({ languageTag: languageTag }), users: m.users({ languageTag: languageTag }), + user: m.user({ languageTag: languageTag }), userGroups: m.userGroups({ languageTag: languageTag }), roleAssignments: m.roleAssignments({ languageTag: languageTag }), xRays: m.xRays({ languageTag: languageTag }), @@ -67,6 +98,7 @@ export function localItems(languageTag: string): LocalItems { category: m.category({ languageTag: languageTag }), eta: m.eta({ languageTag: languageTag }), securityFunction: m.securityFunction({ languageTag: languageTag }), + securityMeasure: m.securityMeasure({ languageTag: languageTag }), provider: m.provider({ languageTag: languageTag }), domain: m.domain({ languageTag: languageTag }), urn: m.urn({ languageTag: languageTag }), diff --git a/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte b/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte index 803629e2f..b677ed9dd 100644 --- a/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte +++ b/frontend/src/routes/(app)/[model=urlmodel]/+page.svelte @@ -11,7 +11,8 @@ import { getModalStore, getToastStore } from '@skeletonlabs/skeleton'; import { superForm } from 'sveltekit-superforms/client'; import type { PageData } from './$types'; - import { localItems } from '$lib/utils/locales'; + import * as m from '$paraglide/messages'; + import { localItems, getDeterminant } from '$lib/utils/locales'; import { languageTag } from '$paraglide/runtime'; export let data: PageData; @@ -93,7 +94,9 @@ class="btn variant-filled-primary self-end" data-testid="add-button" on:click={modalCreateForm} - >New {data.model.verboseName.toLowerCase()} + {m.addButton({determinant:getDeterminant(languageTag(), "undefined", data.model), model: localItems(languageTag())[data.model.localName].toLowerCase()})} + {:else if data.URLModel === 'risk-matrices'} Date: Thu, 15 Feb 2024 14:17:24 +0100 Subject: [PATCH 12/19] feat: end model tables translation --- frontend/messages/en.json | 9 ++++++++- frontend/messages/fr.json | 11 +++++++++-- .../src/lib/components/ModelTable/Pagination.svelte | 5 +++-- .../src/lib/components/ModelTable/RowCount.svelte | 7 +++---- .../src/lib/components/ModelTable/RowsPerPage.svelte | 5 +++-- frontend/src/lib/components/ModelTable/Search.svelte | 3 ++- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 582432be7..e5fb189e5 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -72,5 +72,12 @@ "framework": "Framework", "file": "File", "language": "Language", - "builtin": "Builtin" + "builtin": "Builtin", + "next": "Next", + "previous": "Previous", + "show": "Show", + "entries": "entries", + "searchPlaceholder": "Search...", + "noEntriesFound": "No entries found", + "rowCount": "Showing {start} to {end} of {total}" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index ae29e7d01..0d95424fe 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -38,7 +38,7 @@ "userGroups": "Groupes d'utilisateurs", "roleAssignments": "Affectations de rôle", "xRays": "X-rays", - "scoringAssistant": "Assistat d'évaluation", + "scorAffichageAssistant": "Assistat d'évaluation", "libraries": "Bibliothèques", "backupRestore": "Sauvegarde et restauration", "myProfile": "Mon profil", @@ -72,5 +72,12 @@ "framework": "Cadre", "file": "Fichier", "language": "Langue", - "builtin": "Intégré" + "builtin": "Intégré", + "next": "Suivant", + "previous": "Précédent", + "show": "Afficher", + "entries": "entrées", + "searchPlaceholder": "Rechercher...", + "noEntriesFound": "Aucune entrée trouvée", + "rowCount": "Affichage de {start} à {end} sur {total}" } diff --git a/frontend/src/lib/components/ModelTable/Pagination.svelte b/frontend/src/lib/components/ModelTable/Pagination.svelte index 0f9272a7a..6151c070e 100644 --- a/frontend/src/lib/components/ModelTable/Pagination.svelte +++ b/frontend/src/lib/components/ModelTable/Pagination.svelte @@ -1,5 +1,6 @@ diff --git a/frontend/src/lib/components/ModelTable/RowsPerPage.svelte b/frontend/src/lib/components/ModelTable/RowsPerPage.svelte index 060388b05..8378067ef 100644 --- a/frontend/src/lib/components/ModelTable/RowsPerPage.svelte +++ b/frontend/src/lib/components/ModelTable/RowsPerPage.svelte @@ -1,12 +1,13 @@ diff --git a/frontend/src/lib/components/ModelTable/Search.svelte b/frontend/src/lib/components/ModelTable/Search.svelte index 2a0b1bc9a..95e2d9937 100644 --- a/frontend/src/lib/components/ModelTable/Search.svelte +++ b/frontend/src/lib/components/ModelTable/Search.svelte @@ -1,12 +1,13 @@ handler.search(value)} /> From 97bc8545df692b3c34f24beca0b0ad700a20caba Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 15 Feb 2024 15:33:39 +0100 Subject: [PATCH 13/19] feat: translate generic detailed views --- frontend/messages/en.json | 37 +++++++++++++++- frontend/messages/fr.json | 41 ++++++++++++++++-- frontend/src/lib/utils/locales.ts | 39 +++++++++++++++++ .../[model=urlmodel]/[id=uuid]/+page.svelte | 42 +++++++++++-------- 4 files changed, 135 insertions(+), 24 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index e5fb189e5..7453cad0a 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -44,7 +44,7 @@ "myProfile": "My profile", "aboutCiso": "About CISO Assistant", "Logout": "Log out", - "name": "name", + "name": "Name", "description": "Description", "parentDomain": "Parent domain", "ref": "Ref", @@ -79,5 +79,38 @@ "entries": "entries", "searchPlaceholder": "Search...", "noEntriesFound": "No entries found", - "rowCount": "Showing {start} to {end} of {total}" + "rowCount": "Showing {start} to {end} of {total}", + "status": "Status", + "effort": "Effort", + "impact": "Impact", + "expiryDate": "Expiry date", + "link": "Link", + "createdAt": "Created at", + "updatedAt": "Updated at", + "acceptedAt": "Accepted at", + "rejectedAt": "Rejected at", + "revokedAt": "Revoked at", + "locale": "Locale", + "defaultLocale": "Default locale", + "annotation": "Annotation", + "library": "Library", + "typicalEvidence": "Typical evidence", + "parentAsset": "Parent asset", + "approver": "Approver", + "state": "State", + "justification": "Justification", + "parentFolder": "Parent folder", + "contentType": "Content type", + "lcStatus": "status", + "internalReference": "Internal reference", + "isActive": "Is active", + "dateJoined": "Date joined", + "version": "Version", + "treatment": "Treatment", + "currentProba": "Current probability", + "currentImpact": "Current impact", + "residualProba": "Residual probability", + "residualImpact": "Residual impact", + "existingMeasures": "Existing measures", + "strengthOfKnowledge": "Strength of knowledge" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 0d95424fe..8bde7642d 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -44,7 +44,7 @@ "myProfile": "Mon profil", "aboutCiso": "À propos de CISO Assistant", "Logout": "Se déconnecter", - "name": "nom", + "name": "Nom", "description": "Description", "parentDomain": "Domaine parent", "ref": "Réf", @@ -64,9 +64,9 @@ "treatmentStatus": "Statut de traitement", "currentLevel": "Niveau actuel", "residualLevel": "Niveau résiduel", - "riskMatrix": "Matrice des risques", + "riskMatrix": "Matrice de risque", "project": "Projet", - "folder": "Dossier", + "folder": "Domaine", "riskAssessment": "Évaluation de risque", "threat": "Menace", "framework": "Cadre", @@ -79,5 +79,38 @@ "entries": "entrées", "searchPlaceholder": "Rechercher...", "noEntriesFound": "Aucune entrée trouvée", - "rowCount": "Affichage de {start} à {end} sur {total}" + "rowCount": "Affichage de {start} à {end} sur {total}", + "status": "Statut", + "effort": "Effort", + "impact": "Impact", + "expiryDate": "Date d'expiration", + "link": "Lien", + "createdAt": "Créé le", + "updatedAt": "Mis à jour le", + "acceptedAt": "Accepté le", + "rejectedAt": "Rejeté le", + "revokedAt": "Révoqué le", + "locale": "Locale", + "defaultLocale": "Locale par défaut", + "annotation": "Annotation", + "library": "Bibliothèque", + "typicalEvidence": "Preuve typique", + "parentAsset": "Actif parent", + "approver": "Approbateur", + "state": "État", + "justification": "Justification", + "parentFolder": "Domaine parent", + "contentType": "Type de contenu", + "lcStatus": "Statut", + "internalReference": "Référence interne", + "isActive": "Est actif", + "dateJoined": "Date d'adhésion", + "version": "Version", + "treatment": "Traitement", + "currentProba": "Probabilité actuelle", + "currentImpact": "Impact actuel", + "residualProba": "Probabilité résiduelle", + "residualImpact": "Impact résiduel", + "existingMeasures": "Mesures existantes", + "strengthOfKnowledge": "Expertise" } diff --git a/frontend/src/lib/utils/locales.ts b/frontend/src/lib/utils/locales.ts index 4c8cf2e69..b38e7bf7f 100644 --- a/frontend/src/lib/utils/locales.ts +++ b/frontend/src/lib/utils/locales.ts @@ -12,6 +12,12 @@ export const LOCALE_MAP = { } }; +export function toCamelCase(str: string) { + return str.replace(/[-_]+(.)?/g, function(match, char) { + return char ? char.toUpperCase() : ''; + }); +} + export function getDeterminant(lang: string, defined: string, model: ModelInfo, plural=false): string { const determinantTable = { "fr": { @@ -115,6 +121,39 @@ export function localItems(languageTag: string): LocalItems { file: m.file({ languageTag: languageTag }), language: m.language({ languageTag: languageTag }), builtin: m.builtin({ languageTag: languageTag }), + status: m.status({ languageTag: languageTag }), + effort: m.effort({ languageTag: languageTag }), + impact: m.impact({ languageTag: languageTag }), + expiryDate: m.expiryDate({ languageTag: languageTag }), + link: m.link({ languageTag: languageTag }), + createdAt: m.createdAt({ languageTag: languageTag }), + updatedAt: m.updatedAt({ languageTag: languageTag }), + acceptedAt: m.acceptedAt({ languageTag: languageTag }), + rejectedAt: m.rejectedAt({ languageTag: languageTag }), + revokedAt: m.revokedAt({ languageTag: languageTag }), + locale: m.locale({ languageTag: languageTag }), + defaultLocale: m.defaultLocale({ languageTag: languageTag }), + annotation: m.annotation({ languageTag: languageTag }), + library: m.library({ languageTag: languageTag }), + typicalEvidence: m.typicalEvidence({ languageTag: languageTag }), + parentAsset: m.parentAsset({ languageTag: languageTag }), + approver: m.approver({ languageTag: languageTag }), + state: m.state({ languageTag: languageTag }), + justification: m.justification({ languageTag: languageTag }), + parentFolder: m.parentFolder({ languageTag: languageTag }), + contentType: m.contentType({ languageTag: languageTag }), + lcStatus: m.lcStatus({ languageTag: languageTag }), + internalReference: m.internalReference({ languageTag: languageTag }), + isActive: m.isActive({ languageTag: languageTag }), + dateJoined: m.dateJoined({ languageTag: languageTag }), + version: m.version({ languageTag: languageTag }), + treatment: m.treatment({ languageTag: languageTag }), + currentProba: m.currentProba({ languageTag: languageTag }), + currentImpact: m.currentImpact({ languageTag: languageTag }), + residualProba: m.residualProba({ languageTag: languageTag }), + residualImpact: m.residualImpact({ languageTag: languageTag }), + existingMeasures: m.existingMeasures({ languageTag: languageTag }), + strengthOfKnowledge: m.strengthOfKnowledge({ languageTag: languageTag }) }; return LOCAL_ITEMS; } \ No newline at end of file diff --git a/frontend/src/routes/(app)/[model=urlmodel]/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/[model=urlmodel]/[id=uuid]/+page.svelte index 0b75bb73d..336946251 100644 --- a/frontend/src/routes/(app)/[model=urlmodel]/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/[model=urlmodel]/[id=uuid]/+page.svelte @@ -15,6 +15,8 @@ import { getModelInfo } from '$lib/utils/crud.js'; import { URL_MODEL_MAP } from '$lib/utils/crud'; import { isURL } from '$lib/utils/helpers'; + import { localItems, toCamelCase } from '$lib/utils/locales.js'; + import { languageTag } from '$paraglide/runtime.js'; const modalStore: ModalStore = getModalStore(); const toastStore: ToastStore = getToastStore(); @@ -172,29 +174,33 @@
    {#each Object.entries(data.data).filter(([key, _]) => !['id', 'is_published'].includes(key)) as [key, value]}
    -
    - {key.replace('_', ' ')} +
    + {localItems(languageTag())[toCamelCase(key.toLowerCase())]}
    • {#if value} {#if Array.isArray(value)} - + {#if Object.keys(value).length > 0} +
        + {#each value as val} +
      • + {#if val.str && val.id} + {@const itemHref = `/${ + URL_MODEL_MAP[data.urlModel]['foreignKeyFields']?.find( + (item) => item.field === key + )?.urlModel + }/${val.id}`} + {val.str} + {:else} + {value} + {/if} +
      • + {/each} +
      + {:else} + -- + {/if} {:else if value.id} {@const itemHref = `/${ URL_MODEL_MAP[data.urlModel]['foreignKeyFields']?.find( From ab48be634642e07f1b6826011c9bacccc2be9c9b Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 16 Feb 2024 16:09:55 +0100 Subject: [PATCH 14/19] feat: translate generic modelform and nested tabs --- frontend/messages/en.json | 11 +- frontend/messages/fr.json | 11 +- .../src/lib/components/Forms/ModelForm.svelte | 101 +++++++++--------- frontend/src/lib/utils/crud.ts | 57 ++++++---- frontend/src/lib/utils/locales.ts | 6 +- .../(app)/[model=urlmodel]/+page.svelte | 4 +- .../[model=urlmodel]/[id=uuid]/+page.svelte | 15 ++- 7 files changed, 124 insertions(+), 81 deletions(-) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 7453cad0a..cabcd4a87 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -1,6 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", "addButton": "Add {model}", + "associatedObject": "Associated {model}", "french": "French", "english": "English", "home": "Home", @@ -96,12 +97,13 @@ "library": "Library", "typicalEvidence": "Typical evidence", "parentAsset": "Parent asset", + "parentAssets": "Parent assets", "approver": "Approver", "state": "State", "justification": "Justification", "parentFolder": "Parent folder", "contentType": "Content type", - "lcStatus": "status", + "lcStatus": "Status", "internalReference": "Internal reference", "isActive": "Is active", "dateJoined": "Date joined", @@ -112,5 +114,10 @@ "residualProba": "Residual probability", "residualImpact": "Residual impact", "existingMeasures": "Existing measures", - "strengthOfKnowledge": "Strength of knowledge" + "strengthOfKnowledge": "Strength of knowledge", + "dueDate": "Due date", + "attachment": "Attachment", + "observation": "Observation", + "importMatrices": "Import matrices", + "importFrameworks": "Import frameworks" } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 8bde7642d..141b2b9c8 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -1,6 +1,7 @@ { "$schema": "https://inlang.com/schema/inlang-message-format", "addButton": "Ajouter {determinant} {model}", + "associatedObject": "{model} associé{e}s", "french": "Français", "english": "Anglais", "home": "Accueil", @@ -95,7 +96,8 @@ "annotation": "Annotation", "library": "Bibliothèque", "typicalEvidence": "Preuve typique", - "parentAsset": "Actif parent", + "parentAsset": "Bien sensible parent", + "parentAssets": "Biens sensibles parents", "approver": "Approbateur", "state": "État", "justification": "Justification", @@ -112,5 +114,10 @@ "residualProba": "Probabilité résiduelle", "residualImpact": "Impact résiduel", "existingMeasures": "Mesures existantes", - "strengthOfKnowledge": "Expertise" + "strengthOfKnowledge": "Expertise", + "dueDate": "Date d'échéance", + "attachment": "Pièce jointe", + "observation": "Observation", + "importMatrices": "Importer des matrices", + "importFrameworks": "Importer des cadres" } diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index d28a68a18..9e1afb651 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -16,6 +16,7 @@ import FileInput from './FileInput.svelte'; import { browser } from '$app/environment'; import { page } from '$app/stores'; + import * as m from '$paraglide/messages.js'; export let form: SuperValidated; export let model: ModelInfo; @@ -75,66 +76,66 @@ /> {/if} {#if shape.name} - + {/if} {#if shape.description} -