From 79913872856a47811b97f114a1ceef6b03ce2988 Mon Sep 17 00:00:00 2001 From: David Bondy Date: Tue, 18 Jun 2024 13:36:39 -0600 Subject: [PATCH] Merge pull request #43933 from nkdengineer/fix/42970-regression Add missing translation (cherry picked from commit 2ee7c52fd513cc53dc1c931ef735a510f4ee9dcc) --- src/components/Form/FormProvider.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/Form/FormProvider.tsx b/src/components/Form/FormProvider.tsx index 16ecc3805d2d..bed4cea31829 100644 --- a/src/components/Form/FormProvider.tsx +++ b/src/components/Form/FormProvider.tsx @@ -9,7 +9,6 @@ import * as ValidationUtils from '@libs/ValidationUtils'; import Visibility from '@libs/Visibility'; import * as FormActions from '@userActions/FormActions'; import CONST from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; import type {OnyxFormKey} from '@src/ONYXKEYS'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Form} from '@src/types/form'; @@ -25,7 +24,7 @@ import type {FormInputErrors, FormOnyxValues, FormProps, FormRef, InputComponent // More details: https://github.com/Expensify/App/pull/16444#issuecomment-1482983426 const VALIDATE_DELAY = 200; -type GenericFormInputErrors = Partial>; +type GenericFormInputErrors = Partial>; type InitialDefaultValue = false | Date | ''; function getInitialValueByType(valueType?: ValueTypeKey): InitialDefaultValue { @@ -93,7 +92,7 @@ function FormProvider( }: FormProviderProps, forwardedRef: ForwardedRef, ) { - const {preferredLocale} = useLocalize(); + const {preferredLocale, translate} = useLocalize(); const inputRefs = useRef({}); const touchedInputs = useRef>({}); const [inputValues, setInputValues] = useState
(() => ({...draftValues})); @@ -143,7 +142,7 @@ function FormProvider( } // Add a validation error here because it is a string value that contains HTML characters - validateErrors[inputID] = 'common.error.invalidCharacter'; + validateErrors[inputID] = translate('common.error.invalidCharacter'); }); if (typeof validateErrors !== 'object') { @@ -158,7 +157,7 @@ function FormProvider( return touchedInputErrors; }, - [errors, formID, validate, shouldTrimValues], + [shouldTrimValues, formID, validate, errors, translate], ); // When locales change from another session of the same account,