From 3dc217a832e57a4edfba5262e22b9381e9c60c4a Mon Sep 17 00:00:00 2001 From: jax Date: Fri, 21 Feb 2020 16:36:15 +0000 Subject: [PATCH 1/3] update package.json --- python/hackathon_app/frontend/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/hackathon_app/frontend/package.json b/python/hackathon_app/frontend/package.json index aadca5c..bda4efa 100644 --- a/python/hackathon_app/frontend/package.json +++ b/python/hackathon_app/frontend/package.json @@ -13,11 +13,14 @@ "@types/styled-components": "^4.1.19", "@types/yup": "^0.26.24", "formik": "^1.5.8", + "i18next": "^19.3.1", + "i18next-browser-languagedetector": "^4.0.1", "prettier": "^1.18.2", "react": "^16.10.2", "react-dom": "^16.10.2", "react-google-login": "^5.0.7", - "react-scripts": "3.2.0", + "react-i18next": "^11.3.3", + "react-scripts": "^3.4.0", "styled-components": "^4.4.0", "typescript": "3.6.3", "yup": "^0.27.0" From 0c01d668873b5ca0a1fe5759281349c8b67f1a00 Mon Sep 17 00:00:00 2001 From: jax Date: Fri, 21 Feb 2020 16:46:21 +0000 Subject: [PATCH 2/3] sample translation file --- .../frontend/src/locales/it/translation.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 python/hackathon_app/frontend/src/locales/it/translation.json diff --git a/python/hackathon_app/frontend/src/locales/it/translation.json b/python/hackathon_app/frontend/src/locales/it/translation.json new file mode 100644 index 0000000..cb187d9 --- /dev/null +++ b/python/hackathon_app/frontend/src/locales/it/translation.json @@ -0,0 +1,10 @@ +{ + "Register for a Hackathon": "Registrati per un hackathon", + "textFieldMissingError": "{{field}} รจ obbligatorio", + "textFieldValidationError": "{{field}} deve essere valido", + "first_name": "nome", + "last_name": "congnome", + "email": "email", + "organization": "organizzazione", + "role": "ruolo" +} From 105808e684ab12daf1f83431e90057bf78be004f Mon Sep 17 00:00:00 2001 From: jax Date: Fri, 21 Feb 2020 16:51:38 +0000 Subject: [PATCH 3/3] localize Resources and Register scenes --- .../frontend/src/RegisterScene.tsx | 58 ++++++++++++------- .../frontend/src/ResourcesScene.tsx | 12 ++-- python/hackathon_app/frontend/src/i18n.js | 29 ++++++++++ python/hackathon_app/frontend/src/index.tsx | 21 ++++--- 4 files changed, 86 insertions(+), 34 deletions(-) create mode 100644 python/hackathon_app/frontend/src/i18n.js diff --git a/python/hackathon_app/frontend/src/RegisterScene.tsx b/python/hackathon_app/frontend/src/RegisterScene.tsx index 0fb7497..102fa1d 100644 --- a/python/hackathon_app/frontend/src/RegisterScene.tsx +++ b/python/hackathon_app/frontend/src/RegisterScene.tsx @@ -1,3 +1,4 @@ +import i18n from './i18n' import { Button, Box, @@ -34,7 +35,9 @@ const ValidatedFieldCheckbox: React.FC = ({ return ( = ({ }) => { const error = errors[field.name] const touch = touched[field.name] + const key = + error === 'email must be a valid email' + ? 'textFieldValidationError' + : 'textFieldMissingError' return ( = ({ XXL {error && touch && ( - + )} ) @@ -97,7 +109,9 @@ const ValidatedFieldSelect: React.FC = ({ return ( = () => { return ( <> - Hackathon Registration - Register for a Hackathon below + {i18n.t('Hackathon Registration')} + {i18n.t('Register for a Hackathon below')} - Registration + {i18n.t('Registration')} = () => {
- + = () => { = () => { = () => { {status &&
{status}
} {isSubmitting && } - + ) diff --git a/python/hackathon_app/frontend/src/ResourcesScene.tsx b/python/hackathon_app/frontend/src/ResourcesScene.tsx index a03b63e..290f2ad 100644 --- a/python/hackathon_app/frontend/src/ResourcesScene.tsx +++ b/python/hackathon_app/frontend/src/ResourcesScene.tsx @@ -1,5 +1,6 @@ import React from 'react' import {Button, Heading, Paragraph, Divider} from '@looker/components' +import i18n from './i18n' export const ResourcesScene: React.FC<{path: string}> = ({path}) => { const [name, setName] = React.useState('') @@ -36,15 +37,16 @@ export const ResourcesScene: React.FC<{path: string}> = ({path}) => { return ( <> Looker Hackathons - Find information on Hackathons below + {i18n.t('Find information on Hackathons below')} - {message} + {i18n.t(message)} - Explore the links below to find useful documentation and tools for - participating in a hackathon. + {i18n.t( + 'Explore the links below to find useful documentation and tools for participating in a hackathon.' + )}