Skip to content

Commit 7e33be4

Browse files
committed
feat: translations to error fallbacks
1 parent df5cea5 commit 7e33be4

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { InstrumentErrorFallback } from '@opendatacapture/react-core';
1+
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
22
import type { InstrumentErrorFallbackProps } from '@opendatacapture/react-core';
3+
import { InstrumentErrorFallback } from '@opendatacapture/react-core';
34

45
export const CompileErrorFallback = (props: Omit<InstrumentErrorFallbackProps, 'title'>) => {
5-
return <InstrumentErrorFallback title="Failed to Compile" {...props} />;
6+
const { t } = useTranslation();
7+
return <InstrumentErrorFallback title={t({ en: 'Failed to Compile', fr: 'Échec de la compilation' })} {...props} />;
68
};

apps/playground/src/components/Viewer/RuntimeErrorFallback.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { InstrumentErrorFallback } from '@opendatacapture/react-core';
1+
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
22
import type { InstrumentErrorFallbackProps } from '@opendatacapture/react-core';
3+
import { InstrumentErrorFallback } from '@opendatacapture/react-core';
34

45
export const RuntimeErrorFallback = (props: Omit<InstrumentErrorFallbackProps, 'title'>) => {
6+
const { t } = useTranslation();
57
return (
68
<InstrumentErrorFallback
7-
description="This means that your instrument successfully compiled, but caused an unexpected exception to be thrown in the browser. For example, this could happen in the render function of a dynamic form field. Although the bundler attempts to validate the structure of instruments at compile time, it is not possible to evaluate the runtime behavior of arbitrary JavaScript code."
8-
title="Unhandled Runtime Error"
9+
description={t({
10+
en: 'This means that your instrument successfully compiled, but caused an unexpected exception to be thrown in the browser. For example, this could happen in the render function of a dynamic form field. Although the bundler attempts to validate the structure of instruments at compile time, it is not possible to evaluate the runtime behavior of arbitrary JavaScript code.',
11+
fr: "Cela signifie que votre instrument a été compilé avec succès, mais a provoqué la levée d'une exception inattendue dans le navigateur. Par exemple, cela pourrait se produire dans la fonction de rendu d'un champ de formulaire dynamique. Bien que le bundler tente de valider la structure des instruments lors de la compilation, il n'est pas possible d'évaluer le comportement à l'exécution de code JavaScript arbitraire."
12+
})}
13+
title={t({ en: 'Unhandled Runtime Error', fr: "Erreur d'exécution non gérée" })}
914
{...props}
1015
/>
1116
);

0 commit comments

Comments
 (0)