From cdf575585b91dc34dbda318b4e9dd537f5c6f82f Mon Sep 17 00:00:00 2001 From: willybeans Date: Thu, 6 Feb 2020 16:42:44 -0500 Subject: [PATCH] refactor(fscomponents): FLAGSHIP-94 Add Translations To Component --- .../fscomponents/src/components/LoginForm.tsx | 20 ++++++++++--------- packages/fsi18n/src/translations/en.ts | 4 ++++ packages/fsi18n/src/types.ts | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/fscomponents/src/components/LoginForm.tsx b/packages/fscomponents/src/components/LoginForm.tsx index d371f92dc4..3125208ac6 100644 --- a/packages/fscomponents/src/components/LoginForm.tsx +++ b/packages/fscomponents/src/components/LoginForm.tsx @@ -6,6 +6,8 @@ import * as t from 'tcomb-form-native'; import { emailRegex } from '../lib/email'; import { Form, FormLabelPosition } from './Form'; import { Button } from './Button'; +import FSI18n, { translationKeys } from '@brandingbrand/fsi18n'; +const componentTranslationKeys = translationKeys.flagship.loginForm; export interface LoginFormProps { /** @@ -66,9 +68,9 @@ const EmailType = t.refinement(t.String, (str: string) => { EmailType.getValidationErrorMessage = (s: string) => { if (!s) { - return 'Email is required'; + return FSI18n.string(componentTranslationKeys.emailReq); } else { - return `${s} is not an valid email`; + return s + FSI18n.string(componentTranslationKeys.emailNotValid); } }; @@ -91,23 +93,23 @@ export class LoginForm extends Component { this.fieldsOptions = { emailAddress: { - label: 'Email', - placeholder: 'Email', + label: FSI18n.string(componentTranslationKeys.email), + placeholder: FSI18n.string(componentTranslationKeys.email), returnKeyType: 'next', autoCorrect: false, autoCapitalize: 'none', keyboardType: 'email-address', onSubmitEditing: () => this.focusField('password'), - error: 'Please enter a valid email' + error: FSI18n.string(componentTranslationKeys.emailError) }, password: { - label: 'Password', - placeholder: 'Password', + label: FSI18n.string(componentTranslationKeys.password), + placeholder: FSI18n.string(componentTranslationKeys.password), returnKeyType: 'next', autoCorrect: false, autoCapitalize: 'none', secureTextEntry: true, - error: 'Please enter your password' + error: FSI18n.string(componentTranslationKeys.passwordError) }, ...props.fieldsOptions }; @@ -158,7 +160,7 @@ export class LoginForm extends Component { onChange={this.handleChange} />