Skip to content

[FEATURE]: i18n usage in frontend #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v6y-apps/front/public/images/flags/en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions v6y-apps/front/public/images/flags/fr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions v6y-apps/front/public/locales/en/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"vitality": {
"searchPage": {
"shortTitle": "search",
"inputHelper": "You can search by application name, package name or keyword (eslint, maintainability, ...)",
"inputPlaceholder": "Search pattern",
"inputLabel": "Search application"
},
"dashboardPage": {
"menuTitle": "Choose an option to view the relevant applications",
"pageTitle": "Vitality: Keeping Your Codebase Healthy and High-Performing",
"shortTitle": "dashboard"
},
"appListPage": {
"loadMore": "Click to load more applications",
"openDetails": "See Details",
"pageTitle": "Applications Vitality",
"totalLabel": "Total Applications: ",
"exportLabel": "Export Applications",
"contactEmail": " Contact The Team",
"nbBranches": "Number of opened branches: ",
"shortTitle": "applications"
},
"appDetailsPage": {
"pageTitle": "Application details",
"shortTitle": "application details",
"qualityStatus": {
"title": "Quality Indicators",
"exportLabel": "Export Quality Indicators",
"selectLabel": "Select a branch",
"selectHelper": "Select a branch to filter quality indicators",
"selectPlaceholder": "All"
},
"infos": {
"title": "General Information",
"exportLabel": "Export General Information"
},
"evolutions": {
"title": "Recommendations and Evolutions",
"exportLabel": "Export Evolutions",
"selectLabel": "Select a branch",
"selectHelper": "Select a branch to filter evolutions",
"selectPlaceholder": "All"
},
"dependencies": {
"title": "Dependencies analysis",
"exportLabel": "Export Dependencies",
"selectLabel": "Select a branch",
"selectHelper": "Select a branch to filter dependencies",
"selectPlaceholder": "All"
},
"audit": {
"reportsTitle": "Audit reports",
"exportLabel": "Export Audit Reports",
"statusFailure": "Audit failed",
"selectLabel": "Select a branch",
"selectHelper": "Select a branch to filter metrics",
"selectPlaceholder": "All",
"moduleHelpTitle": "More details about modules",
"detectOnBranch": "Affected branch",
"detectOnPath": "Affected file/module",
"indicatorScore": "Indicator score",
"openApp": "Open application",
"helpTitle": "More details about metrics and issues",
"helpCategory": "Category",
"helpTitleLabel": "Title",
"helpDescription": "Description",
"helpExplanation": "Explanation"
}
},
"appStatsPage": {
"pageTitle": "Health statistics",
"graphTitle": "Health statistics",
"shortTitle": "health statistics",
"graphEmptyMessage": "You should select a filter to display statistics!"
},
"faqPage": {
"pageTitle": "Frequent Questions",
"shortTitle": "faq"
},
"notificationsPage": {
"pageTitle": "Notifications",
"shortTitle": "notifications"
},
"loginPage": {
"formEmail": {
"label": "Email",
"warning": "Please enter a valid email address"
},
"formPassword": {
"label": "Password",
"warning": "Please enter a valid password"
},
"formErrorIncorrectCreds": "Incorrect credentials",
"formErrorConnection": "Connection error",
"formSuccess": "Successful connection",
"formRemember": "Remember me",
"formSubmit": "Login"
}
}
}
101 changes: 101 additions & 0 deletions v6y-apps/front/public/locales/fr/common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"vitality": {
"searchPage": {
"shortTitle": "recherche",
"inputHelper": "Vous pouvez rechercher par nom d'application, nom de package ou mot-clé (eslint, maintenabilité, ...)",
"inputPlaceholder": "Motif de recherche",
"inputLabel": "Recherche d'application"
},
"dashboardPage": {
"menuTitle": "Choisissez une option pour afficher les applications pertinentes",
"pageTitle": "Vitality : Maintenir votre base de code saine et performante",
"shortTitle": "tableau de bord"
},
"appListPage": {
"loadMore": "Cliquez pour charger plus d'applications",
"openDetails": "Voir les détails",
"shortTitle": "applications",
"pageTitle": "Applications Vitality",
"totalLabel": "TOTAL Applications: ",
"exportLabel": "Exporter les applications",
"contactEmail": " Contacter l'équipe",
"nbBranches": "Nombre de branches ouvertes : "
},
"appDetailsPage": {
"pageTitle": "Détail de l'application",
"shortTitle": "détail de l'application",
"qualityStatus": {
"title": "Indicateurs de qualité",
"exportLabel": "Exporter les indicateurs de qualité",
"selectLabel": "Sélectionner une branche",
"selectHelper": "Sélectionnez une branche pour filtrer les indicateurs de qualité",
"selectPlaceholder": "Tous"
},
"infos": {
"title": "Informations générales",
"exportLabel": "Exporter les informations de l'application"
},
"evolutions": {
"title": "Recommandations et évolutions",
"exportLabel": "Exporter les évolutions",
"selectLabel": "Sélectionner une branche",
"selectHelper": "Sélectionnez une branche pour filtrer les évolutions",
"selectPlaceholder": "Tous"
},
"dependencies": {
"title": "Analyse des dépendances",
"exportLabel": "Exporter les dépendances",
"selectLabel": "Sélectionner une branche",
"selectHelper": "Sélectionnez une branche pour filtrer les dépendances",
"selectPlaceholder": "Tous"
},
"audit": {
"reportsTitle": "Rapports d'audit",
"exportLabel": "Exporter les rapports d'audit",
"statusFailure": "Audit échoué",
"selectLabel": "Sélectionner une branche",
"selectHelper": "Sélectionnez une branche pour filtrer les métriques",
"selectPlaceholder": "Tous",
"moduleHelpTitle": "Plus de détails sur les modules",
"detectOnBranch": "Branche affectée",
"detectOnPath": "Fichier/module affecté",
"indicatorScore": "Score de l'indicateur",
"openApp": "Ouvrir l'application",
"helpTitle": "Plus de détails sur les métriques et problèmes",
"helpCategory": "Catégorie",
"helpTitleLabel": "Titre",
"helpDescription": "Description",
"helpExplanation": "Explication"
}
},
"appStatsPage": {
"pageTitle": "Statistiques de santé",
"graphTitle": "Statistiques de santé",
"shortTitle": "statistiques de santé",
"graphEmptyMessage": "Vous devez sélectionner un filtre pour afficher les statistiques !"
},
"faqPage": {
"pageTitle": "Questions fréquentes",
"shortTitle": "faq"
},
"notificationsPage": {
"pageTitle": "Notifications",
"shortTitle": "notifications"
},
"loginPage": {
"formEmail": {
"label": "Email",
"warning": "Veuillez entrer une adresse e-mail valide"
},
"formPassword": {
"label": "Mot de passe",
"warning": "Veuillez entrer un mot de passe valide"
},
"formErrorIncorrectCreds": "Identifiants incorrects",
"formErrorConnection": "Erreur de connexion",
"formSuccess": "Connexion réussie",
"formRemember": "Se souvenir de moi",
"formSubmit": "Connexion"
}
}
}
5 changes: 4 additions & 1 deletion v6y-apps/front/setupTests.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { cleanup } from '@testing-library/react';
import { List } from '@v6y/ui-kit';
import { List, useTranslationProvider } from '@v6y/ui-kit';
import dynamic from 'next/dynamic';
import { afterEach, beforeEach, vi } from 'vitest';

@@ -32,6 +32,9 @@ afterEach(() => {

vi.mock('@v6y/ui-kit', () => {
return {
useTranslationProvider: vi.fn(() => ({
translate: (key: string) => key
})),
useNavigationAdapter: vi.fn(() => {
return {
createUrlQueryParam: vi.fn((key, value) => `${key}=${value}`),
Original file line number Diff line number Diff line change
@@ -55,7 +55,9 @@ describe('VitalityEvolutionsView', () => {
render(<VitalityEvolutionsView />);

await waitFor(() => {
expect(screen.getByText('Recommendations and Evolutions')).toBeInTheDocument();
expect(
screen.getByText('vitality.appDetailsPage.evolutions.title'),
).toBeInTheDocument();
expect(screen.getByText('Dark Mode')).toBeInTheDocument();
});
});
@@ -192,7 +194,9 @@ describe('VitalityEvolutionsView', () => {

await waitFor(() => {
expect(screen.getAllByRole('option')).toHaveLength(4);
expect(screen.getAllByRole('option')[0]).toHaveTextContent('All');
expect(screen.getAllByRole('option')[0]).toHaveTextContent(
'vitality.appDetailsPage.evolutions.selectPlaceholder',
);
expect(screen.getAllByRole('option')[1]).toHaveTextContent('All');
expect(screen.getAllByRole('option')[2]).toHaveTextContent('i18n');
expect(screen.getAllByRole('option')[3]).toHaveTextContent('ui-update');
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ describe('VitalityGeneralInformationView', () => {
await waitFor(() => {
expect(screen.getByText('Vitality App')).toBeInTheDocument();
expect(screen.getByText('A powerful application for testing.')).toBeInTheDocument();
expect(screen.getByText('Number of opened branches: 2')).toBeInTheDocument();
expect(screen.getByText('vitality.appListPage.nbBranches2')).toBeInTheDocument();
expect(screen.getByText('Vitality Org')).toBeInTheDocument();
expect(screen.getByText('Website')).toBeInTheDocument();
expect(screen.getByText('Documentation')).toBeInTheDocument();
Original file line number Diff line number Diff line change
@@ -24,12 +24,13 @@ describe('VitalityLighthouseReportItem', () => {
render(<VitalityLighthouseReportItem report={report} onOpenHelpClicked={vi.fn()} />);

expect(screen.getByText('Lighthouse')).toBeInTheDocument();
expect(screen.getByText('Category: Performance')).toBeInTheDocument();
expect(
screen.getByText('vitality.appDetailsPage.audit.helpCategory: Performance'),
).toBeInTheDocument();
expect(screen.getByTestId('mock-statistic')).toHaveTextContent('92%');
expect(screen.getByRole('link', { name: 'Open application' })).toHaveAttribute(
'href',
'https://example.com',
);
expect(
screen.getByRole('link', { name: 'vitality.appDetailsPage.audit.openApp' }),
).toHaveAttribute('href', 'https://example.com');
});

it('triggers onOpenHelpClicked when info button is clicked', () => {
@@ -71,7 +72,9 @@ describe('VitalityLighthouseReportItem', () => {
render(<VitalityLighthouseReportItem report={report} onOpenHelpClicked={vi.fn()} />);

expect(screen.getByText('Lighthouse')).toBeInTheDocument();
expect(screen.getByText('Category: Accessibility')).toBeInTheDocument();
expect(
screen.getByText('vitality.appDetailsPage.audit.helpCategory: Accessibility'),
).toBeInTheDocument();
expect(screen.getByTestId('mock-statistic')).toHaveTextContent('0');
expect(screen.queryByRole('link')).not.toBeInTheDocument();
});
@@ -88,7 +91,9 @@ describe('VitalityLighthouseReportItem', () => {

render(<VitalityLighthouseReportItem report={report} onOpenHelpClicked={vi.fn()} />);

expect(screen.getByText('Category: Accessibility')).toBeInTheDocument(); // Assuming default text
expect(
screen.getByText('vitality.appDetailsPage.audit.helpCategory: Accessibility'),
).toBeInTheDocument(); // Assuming default text
});

it('handles extreme score values correctly', () => {
Original file line number Diff line number Diff line change
@@ -53,11 +53,15 @@ describe('VitalityQualityIndicatorsView', () => {
render(<VitalityQualityIndicatorsView />);

await waitFor(() => {
expect(screen.getByText('Quality Indicators')).toBeInTheDocument();
expect(
screen.getByText('vitality.appDetailsPage.qualityStatus.title'),
).toBeInTheDocument();
expect(screen.getByText('Performance')).toBeInTheDocument();

expect(screen.getAllByRole('option')).toHaveLength(4);
expect(screen.getAllByRole('option')[0]).toHaveTextContent('All');
expect(screen.getAllByRole('option')[0]).toHaveTextContent(
'vitality.appDetailsPage.qualityStatus.selectPlaceholder',
);
expect(screen.getAllByRole('option')[1]).toHaveTextContent('All');
expect(screen.getAllByRole('option')[2]).toHaveTextContent('main');
expect(screen.getAllByRole('option')[3]).toHaveTextContent('develop');
@@ -166,7 +170,9 @@ describe('VitalityQualityIndicatorsView', () => {
expect(screen.getAllByRole('button')[1]).toHaveTextContent('warning');
expect(screen.getAllByRole('button')[2]).toHaveTextContent('success');

expect(screen.getByText('Quality Indicators')).toBeInTheDocument();
expect(
screen.getByText('vitality.appDetailsPage.qualityStatus.title'),
).toBeInTheDocument();
expect(screen.getByText('Maintainability')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -38,12 +38,8 @@ describe('VitalityAppListView', () => {

it('renders search bar, selectable indicators, and app list', async () => {
render(<VitalityAppListView />);
expect(screen.getByText('Search application')).toBeInTheDocument();
expect(
screen.getByText(
'You can search by application name, package name or keyword (eslint, maintainability, ...)',
),
).toBeInTheDocument();
expect(screen.getByText('vitality.searchPage.inputLabel')).toBeInTheDocument();
expect(screen.getByText('vitality.searchPage.inputHelper')).toBeInTheDocument();
expect(screen.getByTestId('mock-search-input')).toBeInTheDocument();
});

@@ -98,7 +94,7 @@ describe('VitalityAppListView', () => {
render(<VitalityAppListHeader onExportApplicationsClicked={vi.fn()} />);

await waitFor(() => {
expect(screen.getByText('TOTAL Applications: 25')).toBeInTheDocument();
expect(screen.getByText('vitality.appListPage.totalLabel 25')).toBeInTheDocument();
});
});
});
Loading