Skip to content
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

#12930 Moved hardcoded text from App.tsx to language files #13181

Merged
merged 12 commits into from
Jul 18, 2024
4 changes: 2 additions & 2 deletions frontend/dashboard/app/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('App', () => {
expect(
await screen.findByRole('heading', {
level: 1,
name: 'Feil oppstod ved innlasting av brukerdata',
name: textMock('dashboard.error_getting_user_data.title'),
}),
).toBeInTheDocument();
});
Expand All @@ -36,7 +36,7 @@ describe('App', () => {
expect(
await screen.findByRole('heading', {
level: 1,
name: 'Feil oppstod ved innlasting av organisasjoner',
name: textMock('dashboard.error_getting_organization_data.title'),
}),
);
});
Expand Down
14 changes: 6 additions & 8 deletions frontend/dashboard/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ export const App = (): JSX.Element => {
const componentHasError = isUserError || isOrganizationsError;

const getErrorMessage = (): { title: string; message: string } => {
const defaultTitle = 'Feil oppstod ved innlasting av';
const defaultMessage = 'Vi beklager men en feil oppstod ved henting av';
if (isUserError) {
return {
title: `${defaultTitle} brukerdata`,
message: `${defaultMessage} dine brukerdata.`,
title: t('dashboard.error_getting_user_data.title'),
message: t('dashboard.error_getting_user_data.message'),
};
}
if (isOrganizationsError) {
return {
title: `${defaultTitle} organisasjoner`,
message: `${defaultMessage} organisasjoner som kreves for å kjøre applikasjonen.`,
title: t('dashboard.error_getting_organization_data.title'),
message: t('dashboard.error_getting_organization_data.message'),
};
}
return {
title: 'Ukjent feil oppstod',
message: 'Vi beklager men en ukjent feil, vennligst prøv igjen senere.',
title: t('dashboard.error_unknown.title'),
message: t('dashboard.error_unknown.message'),
};
};

Expand Down
6 changes: 6 additions & 0 deletions frontend/language/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
"dashboard.data_models": "Data models",
"dashboard.description": "Description",
"dashboard.edit_app": "Edit {{appName}} in Studio",
"dashboard.error_getting_organization_data.message": "We apologize, but an error occurred while retrieving organizations required to run the application.",
"dashboard.error_getting_organization_data.title": "An error occurred while loading organizations",
"dashboard.error_getting_user_data.message": "We apologize, but an error occurred when retrieving your user data.",
"dashboard.error_getting_user_data.title": "An error occurred when loading user data",
"dashboard.error_unknown.message": "We are sorry but an unknown error occurred, please try again later.",
"dashboard.error_unknown.title": "An unknown error occurred",
"dashboard.favorite_status": "Favorite status",
"dashboard.favourites": "Favourites",
"dashboard.field_cannot_be_empty": "Field cannot be empty",
Expand Down
6 changes: 6 additions & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
"dashboard.data_models": "Datamodeller",
"dashboard.description": "Beskrivelse",
"dashboard.edit_app": "Endre {{appName}} i Studio",
"dashboard.error_getting_organization_data.message": "Vi beklager men en feil oppstod ved henting av organisasjoner som kreves for å kjøre applikasjonen.",
"dashboard.error_getting_organization_data.title": "Feil oppstod ved innlasting av organisasjoner",
"dashboard.error_getting_user_data.message": "Vi beklager men en feil oppstod ved henting av dine brukerdata.",
"dashboard.error_getting_user_data.title": "Feil oppstod ved innlasting av brukerdata",
"dashboard.error_unknown.message": "Vi beklager men en ukjent feil oppstod, vennligst prøv igjen senere.",
"dashboard.error_unknown.title": "Ukjent feil oppstod",
"dashboard.favorite_status": "Favorittstatus",
"dashboard.favourites": "Favoritter",
"dashboard.field_cannot_be_empty": "Dette feltet kan ikke være tomt",
Expand Down