From 80eaec02660878a992045ac31667819f4ed04814 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:24:38 -0400 Subject: [PATCH 1/6] fix: update localization keys for common, risk, and settings - Added new localization keys for frequency options (monthly, quarterly, yearly) in common. - Introduced new keys for risk department and its placeholder in the risk feature. - Added a delete confirmation message in settings and a new home navigation message in the error handling section. --- apps/app/src/locales/core/common.ts | 5 +++++ apps/app/src/locales/features/risk.ts | 2 ++ apps/app/src/locales/settings/settings.ts | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/app/src/locales/core/common.ts b/apps/app/src/locales/core/common.ts index 6cdbaad920..1e19279591 100644 --- a/apps/app/src/locales/core/common.ts +++ b/apps/app/src/locales/core/common.ts @@ -143,4 +143,9 @@ export const common = { edit: "Edit", description: "Description", last_updated: "Last Updated", + frequency: { + monthly: "Monthly", + quarterly: "Quarterly", + yearly: "Yearly" + } } as const \ No newline at end of file diff --git a/apps/app/src/locales/features/risk.ts b/apps/app/src/locales/features/risk.ts index 61b1abe1cf..b51cab796b 100644 --- a/apps/app/src/locales/features/risk.ts +++ b/apps/app/src/locales/features/risk.ts @@ -20,6 +20,8 @@ export const risk = { risk_category_placeholder: "Select risk category", risk_description: "Description", risk_description_description: "Enter risk description", + risk_department: "Department", + risk_department_placeholder: "Select department", risk_status: "Status", risk_status_placeholder: "Select status" }, diff --git a/apps/app/src/locales/settings/settings.ts b/apps/app/src/locales/settings/settings.ts index e3faf647ca..1264a3b0ce 100644 --- a/apps/app/src/locales/settings/settings.ts +++ b/apps/app/src/locales/settings/settings.ts @@ -18,6 +18,7 @@ export const settings = { org_delete_alert_description: "This action cannot be undone. This will permanently delete your organization and remove your data from our servers.", delete_confirm_tip: "Type 'delete' to confirm", + delete_confirm: "delete", org_delete_error: "Error deleting organization", org_delete_success: "Organization deleted", org_name_updated: "Organization name updated", @@ -139,7 +140,8 @@ export const settings = { "Send an invitation to a new team member to join your organization", error: { title: "Invitation Error", - description: "There was an error processing your invitation." + description: "There was an error processing your invitation.", + home: "Go to Home" }, form: { email: { From 7a61c886eb1c08040efecb4fbaa0093b178003a6 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:29:39 -0400 Subject: [PATCH 2/6] fix: enhance localization keys across various modules - Added new localization keys for onboarding, common statuses, and risk descriptions to improve clarity and consistency. - Introduced keys for excluded translation checks to streamline unused key detection. - Updated existing keys in the risk and settings modules to enhance user experience and provide better context. --- apps/app/src/locales/analyze-locale-usage.ts | 12 +++++++++ apps/app/src/locales/auth/onboarding.ts | 1 + apps/app/src/locales/core/common.ts | 3 +++ apps/app/src/locales/features/risk.ts | 28 +++++++++++++++++--- apps/app/src/locales/settings/settings.ts | 4 +++ 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/apps/app/src/locales/analyze-locale-usage.ts b/apps/app/src/locales/analyze-locale-usage.ts index 6b77753f7f..b2c761b989 100644 --- a/apps/app/src/locales/analyze-locale-usage.ts +++ b/apps/app/src/locales/analyze-locale-usage.ts @@ -16,6 +16,13 @@ const SEARCH_DIRECTORIES = ['./src', './../portal/src'] // Always exclude node_modules from search const EXCLUDE_DIR = '--exclude-dir=node_modules' +// Keys to exclude from unused check +const EXCLUDE_KEYS = [ + 'common.frequency.monthly', + 'common.frequency.quarterly', + 'common.frequency.yearly' +] + // ANSI color codes for terminal output - using a minimal set const COLORS = { reset: '\x1b[0m', @@ -118,6 +125,11 @@ async function findTranslationIssues(findUnused: boolean, findDuplicates: boolea process.stdout.write(`\r${COLORS.gray}Progress: ${percent}% (${count}/${total})${COLORS.reset}`) } + // Skip excluded keys + if (EXCLUDE_KEYS.includes(key)) { + continue + } + const isUsed = await isKeyUsedInCode(key) if (!isUsed) { unusedKeys.push(key) diff --git a/apps/app/src/locales/auth/onboarding.ts b/apps/app/src/locales/auth/onboarding.ts index efd0949f96..e1f6a55e0d 100644 --- a/apps/app/src/locales/auth/onboarding.ts +++ b/apps/app/src/locales/auth/onboarding.ts @@ -31,4 +31,5 @@ export const onboarding = { success: "Thanks, you're all set!", error: "Something went wrong, please try again.", creating: "Creating your organization...", + switch: "Switching organization...", } as const \ No newline at end of file diff --git a/apps/app/src/locales/core/common.ts b/apps/app/src/locales/core/common.ts index 1e19279591..301f8cffc6 100644 --- a/apps/app/src/locales/core/common.ts +++ b/apps/app/src/locales/core/common.ts @@ -39,6 +39,9 @@ export const common = { needs_review: "Needs Review", draft: "Draft", not_assessed: "Not Assessed", + assessed: "Assessed", + active: "Active", + inactive: "Inactive", title: "Status", }, filters: { diff --git a/apps/app/src/locales/features/risk.ts b/apps/app/src/locales/features/risk.ts index b51cab796b..505e3eb9ee 100644 --- a/apps/app/src/locales/features/risk.ts +++ b/apps/app/src/locales/features/risk.ts @@ -7,10 +7,16 @@ export const risk = { form: { update_inherent_risk_success: "Inherent risk updated successfully", update_inherent_risk_error: "Failed to update inherent risk", + update_inherent_risk: "Update Inherent Risk", + update_inherent_risk_description: "Adjust the inherent risk before any controls are applied", update_residual_risk_success: "Residual risk updated successfully", update_residual_risk_error: "Failed to update residual risk", + update_residual_risk: "Update Residual Risk", + update_residual_risk_description: "Adjust the residual risk after controls have been applied", update_risk_success: "Risk updated successfully", update_risk_error: "Failed to update risk", + update_risk: "Update Risk", + update_risk_description: "Update risk details and metadata", create_risk_success: "Risk created successfully", create_risk_error: "Failed to create risk", risk_title: "Risk Title", @@ -31,22 +37,38 @@ export const risk = { risk: "Risk" }, empty: { - create_risk: "Create Risk" + create_risk: "Create Risk", + no_risks: { + title: "No risks yet", + description: "Get started by creating your first risk" + } } }, dashboard: { title: "Risk Dashboard", by_department: "Risks by Department", status: "Risks by Status", - risks_by_assignee: "Risks by Assignee" + risks_by_assignee: "Risks by Assignee", + overview: "Overview", + inherent_risk_description: "Initial risk level before any controls are applied", + residual_risk_description: "Remaining risk level after controls are applied" }, metrics: { probability: "Probability", - impact: "Impact" + impact: "Impact", + inherentRisk: "Inherent Risk", + residualRisk: "Residual Risk" }, tasks: { title: "Tasks", task_overview: "Task Overview", + attachments: "Attachments", + overview: "Overview", + sheet: { + title: "Create Task", + update: "Update Task", + update_description: "Update task details and metadata" + }, form: { title: "Task Details", task_title: "Task Title", diff --git a/apps/app/src/locales/settings/settings.ts b/apps/app/src/locales/settings/settings.ts index 1264a3b0ce..de19dc6589 100644 --- a/apps/app/src/locales/settings/settings.ts +++ b/apps/app/src/locales/settings/settings.ts @@ -92,6 +92,10 @@ export const settings = { description: "There are no active members in your organization", }, }, + status: { + accepted: "Accepted", + pending: "Pending" + }, role: { owner: "Owner", admin: "Admin", From 1fd38695f1a24cedc4e7f49e6c0a09d17c7aa8b7 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:32:11 -0400 Subject: [PATCH 3/6] fix: enhance localization for status policies and translation checks - Added new translation keys for relevant and not-relevant statuses in the policies localization. - Implemented a mapping function for status translations to improve clarity in the StatusPolicies component. - Updated the unused key detection logic to support wildcard patterns for better flexibility in excluding keys. --- apps/app/src/components/status-policies.tsx | 22 +++++++++++++++++++- apps/app/src/locales/analyze-locale-usage.ts | 18 +++++++++++----- apps/app/src/locales/features/policies.ts | 2 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/apps/app/src/components/status-policies.tsx b/apps/app/src/components/status-policies.tsx index cf2efad284..44ab6eb659 100644 --- a/apps/app/src/components/status-policies.tsx +++ b/apps/app/src/components/status-policies.tsx @@ -21,6 +21,26 @@ const STATUS_COLORS: Record = { "not-relevant": "#ff0000", } as const; +// Map status types to translation keys +const getStatusTranslation = (status: StatusType, t: ReturnType) => { + switch (status) { + case "draft": + return t("policies.status.draft"); + case "published": + return t("policies.status.published"); + case "archived": + return t("policies.status.archived"); + case "needs_review": + return t("policies.status.needs_review"); + case "relevant": + return t("policies.status.relevant"); + case "not-relevant": + return t("policies.status.not-relevant"); + default: + return status; + } +}; + export function StatusPolicies({ status, className, @@ -38,7 +58,7 @@ export function StatusPolicies({ className={cn("size-2.5")} style={{ backgroundColor: STATUS_COLORS[status] ?? " " }} /> - {withLabel ? t(`policies.status.${status}`) : null} + {withLabel ? getStatusTranslation(status, t) : null} ); } diff --git a/apps/app/src/locales/analyze-locale-usage.ts b/apps/app/src/locales/analyze-locale-usage.ts index b2c761b989..5a560d6425 100644 --- a/apps/app/src/locales/analyze-locale-usage.ts +++ b/apps/app/src/locales/analyze-locale-usage.ts @@ -17,10 +17,9 @@ const SEARCH_DIRECTORIES = ['./src', './../portal/src'] const EXCLUDE_DIR = '--exclude-dir=node_modules' // Keys to exclude from unused check +// Supports wildcards with * at the end, e.g. 'common.frequency.*' const EXCLUDE_KEYS = [ - 'common.frequency.monthly', - 'common.frequency.quarterly', - 'common.frequency.yearly' + // 'common.frequency.*', ] // ANSI color codes for terminal output - using a minimal set @@ -125,8 +124,17 @@ async function findTranslationIssues(findUnused: boolean, findDuplicates: boolea process.stdout.write(`\r${COLORS.gray}Progress: ${percent}% (${count}/${total})${COLORS.reset}`) } - // Skip excluded keys - if (EXCLUDE_KEYS.includes(key)) { + // Skip excluded keys - now with wildcard support + const isExcluded = EXCLUDE_KEYS.some(excludePattern => { + if (excludePattern.endsWith('*')) { + // For wildcard patterns, check if the key starts with the pattern minus the * + const prefix = excludePattern.slice(0, -1) + return key.startsWith(prefix) + } + return key === excludePattern + }) + + if (isExcluded) { continue } diff --git a/apps/app/src/locales/features/policies.ts b/apps/app/src/locales/features/policies.ts index 788d0f6484..e6f0a3069c 100644 --- a/apps/app/src/locales/features/policies.ts +++ b/apps/app/src/locales/features/policies.ts @@ -62,6 +62,8 @@ export const policies = { published: "Published", needs_review: "Needs Review", archived: "Archived", + relevant: "Relevant", + "not-relevant": "Not Relevant" }, policies: "policies", title: "Policies", From def0dfc36a20f5ef9a7dce8e22ac3014b0ddfc21 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:33:10 -0400 Subject: [PATCH 4/6] fix: update unused key detection to include new localization patterns - Added 'common.status.*' to the list of excluded keys for unused localization checks. - Enhanced flexibility in detecting unused translation keys by supporting wildcard patterns. --- apps/app/src/locales/analyze-locale-usage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/app/src/locales/analyze-locale-usage.ts b/apps/app/src/locales/analyze-locale-usage.ts index 5a560d6425..ce0ff9c1fe 100644 --- a/apps/app/src/locales/analyze-locale-usage.ts +++ b/apps/app/src/locales/analyze-locale-usage.ts @@ -19,7 +19,8 @@ const EXCLUDE_DIR = '--exclude-dir=node_modules' // Keys to exclude from unused check // Supports wildcards with * at the end, e.g. 'common.frequency.*' const EXCLUDE_KEYS = [ - // 'common.frequency.*', + 'common.frequency.*', + 'common.status.*', ] // ANSI color codes for terminal output - using a minimal set From 4aa65ffc1835644a9c630d2022e015cb6e119604 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:34:46 -0400 Subject: [PATCH 5/6] fix: update localization export type for consistency - Changed the export type of translations from DeepReadonly to Readonly for improved type consistency across the application. --- apps/app/src/locales/en.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/app/src/locales/en.ts b/apps/app/src/locales/en.ts index 9067e20181..cb408d6775 100644 --- a/apps/app/src/locales/en.ts +++ b/apps/app/src/locales/en.ts @@ -1,5 +1,3 @@ -import type { DeepReadonly } from 'next/dist/shared/lib/deep-readonly' - // Core translations used across the application import { common } from './core/common' import { errors } from './core/errors' @@ -63,4 +61,4 @@ const translations = { } as const export type Translations = typeof translations -export default translations as DeepReadonly +export default translations as Readonly From 97603da32f73882cbc52199db7e45b02e9af3c62 Mon Sep 17 00:00:00 2001 From: Claudio Fuentes Date: Fri, 21 Mar 2025 15:37:36 -0400 Subject: [PATCH 6/6] fix: update localization export to named export - Changed the export of translations from a constant to a named export for improved modularity and consistency in localization handling. --- apps/app/src/locales/en.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/app/src/locales/en.ts b/apps/app/src/locales/en.ts index cb408d6775..a50985109f 100644 --- a/apps/app/src/locales/en.ts +++ b/apps/app/src/locales/en.ts @@ -27,7 +27,7 @@ import { vendors } from './features/vendors' // Settings translations import { settings } from './settings/settings' -const translations = { +export const translations = { // Core common, errors, @@ -61,4 +61,4 @@ const translations = { } as const export type Translations = typeof translations -export default translations as Readonly +export default translations