From 2534ff289e503903b94ebbca150763059a56431c Mon Sep 17 00:00:00 2001
From: Ben Grant
Date: Tue, 18 May 2021 21:28:14 +1000
Subject: [PATCH] Use i18next and extract strings
---
crabfit-frontend/package.json | 4 ++
.../public/i18n/en-US/common.json | 63 +++++++++++++++++
crabfit-frontend/public/i18n/en-US/event.json | 62 ++++++++++++++++
crabfit-frontend/public/i18n/en-US/help.json | 23 ++++++
crabfit-frontend/public/i18n/en-US/home.json | 57 +++++++++++++++
.../public/i18n/en-US/privacy.json | 52 ++++++++++++++
crabfit-frontend/src/App.tsx | 4 +-
.../AvailabilityEditor/AvailabilityEditor.tsx | 7 +-
.../AvailabilityViewer/AvailabilityViewer.tsx | 8 ++-
.../CalendarField/CalendarField.tsx | 19 +++--
.../src/components/Donate/Donate.tsx | 16 +++--
.../src/components/Footer/Footer.tsx | 12 ++--
.../GoogleCalendar/GoogleCalendar.tsx | 16 +++--
.../src/components/Legend/Legend.tsx | 8 ++-
.../components/SelectField/SelectField.tsx | 18 +++--
.../SelectField/selectFieldStyle.ts | 10 +++
.../src/components/Settings/Settings.tsx | 56 +++++++++++----
.../components/ToggleField/ToggleField.tsx | 14 ++--
crabfit-frontend/src/i18n/index.ts | 28 ++++++++
crabfit-frontend/src/index.tsx | 1 +
crabfit-frontend/src/pages/Event/Event.tsx | 56 +++++++--------
crabfit-frontend/src/pages/Help/Help.tsx | 36 +++++-----
crabfit-frontend/src/pages/Home/Home.tsx | 48 +++++++------
crabfit-frontend/src/pages/Home/homeStyle.ts | 2 +
.../src/pages/Privacy/Privacy.tsx | 70 ++++++++++---------
crabfit-frontend/yarn.lock | 60 ++++++++++++++++
26 files changed, 588 insertions(+), 162 deletions(-)
create mode 100644 crabfit-frontend/public/i18n/en-US/common.json
create mode 100644 crabfit-frontend/public/i18n/en-US/event.json
create mode 100644 crabfit-frontend/public/i18n/en-US/help.json
create mode 100644 crabfit-frontend/public/i18n/en-US/home.json
create mode 100644 crabfit-frontend/public/i18n/en-US/privacy.json
create mode 100644 crabfit-frontend/src/i18n/index.ts
diff --git a/crabfit-frontend/package.json b/crabfit-frontend/package.json
index 785e94c..7660c55 100644
--- a/crabfit-frontend/package.json
+++ b/crabfit-frontend/package.json
@@ -15,9 +15,13 @@
"axios": "^0.21.1",
"dayjs": "^1.10.4",
"gapi-script": "^1.2.0",
+ "i18next": "^20.2.4",
+ "i18next-browser-languagedetector": "^6.1.1",
+ "i18next-http-backend": "^1.2.4",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-hook-form": "^6.15.4",
+ "react-i18next": "^11.8.15",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"typescript": "^4.2.2",
diff --git a/crabfit-frontend/public/i18n/en-US/common.json b/crabfit-frontend/public/i18n/en-US/common.json
new file mode 100644
index 0000000..c72a679
--- /dev/null
+++ b/crabfit-frontend/public/i18n/en-US/common.json
@@ -0,0 +1,63 @@
+{
+ "name": "Crab Fit",
+ "tagline": "Create your own",
+ "cta": "Create your own Crab Fit!",
+ "created": "Created",
+ "donate": {
+ "info": "Thank you for using Crab Fit. If you like it, consider donating.",
+ "button": "Donate",
+ "title": "Every amount counts :)",
+ "options": {
+ "$2": "Donate $2",
+ "$5": "Donate $5",
+ "$10": "Donate $10",
+ "choose": "Choose an amount"
+ },
+ "messages": {
+ "about": "Did you know that Crab Fit costs more that $100 per month? If it's helped you out at all, consider donating to help keep it running. 🦀",
+ "success": "Thank you for your donation! Without you, Crab Fit wouldn't be free, so thank you and keep being super awesome!",
+ "error": "Cannot make donation through Google. Please try donating through the website crab.fit 🦀"
+ }
+ },
+ "options": {
+ "name": "Options",
+ "weekStart": {
+ "label": "Week starts on",
+ "options": {
+ "Sunday": "Sunday",
+ "Monday": "Monday"
+ }
+ },
+ "timeFormat": {
+ "label": "Time format",
+ "options": {
+ "12h": "12h",
+ "24h": "24h"
+ }
+ },
+ "theme": {
+ "label": "Theme",
+ "options": {
+ "System": "System",
+ "Light": "Light",
+ "Dark": "Dark"
+ }
+ },
+ "highlight": {
+ "label": "Highlight highest availability",
+ "title": "Make the highest availability on the heatmap stand out",
+ "options": {
+ "Off": "Off",
+ "On": "On"
+ }
+ },
+ "language": {
+ "label": "Language",
+ "options": {
+ "en-US": "English (US)",
+ "de": "German",
+ "cimode": "Dev (keys)"
+ }
+ }
+ }
+}
diff --git a/crabfit-frontend/public/i18n/en-US/event.json b/crabfit-frontend/public/i18n/en-US/event.json
new file mode 100644
index 0000000..08a5df6
--- /dev/null
+++ b/crabfit-frontend/public/i18n/en-US/event.json
@@ -0,0 +1,62 @@
+{
+ "available": "available",
+
+ "nav": {
+ "title": "Click to copy",
+ "copied": "Copied!",
+ "shareinfo": "Copy the link to this page, or share via <1>email1>.",
+ "email_subject": "Scheduling {{event_name}}",
+ "email_body": "Visit this link to enter your availabilities:"
+ },
+ "form": {
+ "signed_out": "Sign in to add your availability",
+ "signed_in": "Signed in as {{name}}",
+
+ "name": "Your name",
+ "password": "Password (optional)",
+ "button": "Login",
+ "info": "These details are only for this event. Use a password to prevent others from changing your availability.",
+
+ "timezone": "Your time zone",
+
+ "errors": {
+ "password_incorrect": "Password is incorrect. Check your name is spelled right.",
+ "unknown": "Failed to login. Please try again."
+ },
+
+ "created_in_timezone": "This event was created in the timezone {{timezone}}. <3>Click here3> to use it.",
+ "local_timezone": "Your local timezone is detected to be {{timezone}}. <3>Click here3> to use it."
+ },
+ "offline": {
+ "title": "You are offline",
+ "body": "A Crab Fit doesn't work offline. Make sure you're connected to the internet and try again."
+ },
+ "error": {
+ "title": "Event not found",
+ "body": "Check that the url you entered is correct."
+ },
+
+ "tabs": {
+ "you": "Your availability",
+ "you_tooltip": "Login to set your availability",
+ "group": "Group availability"
+ },
+
+ "group": {
+ "legend_tooltip": "Click to highlight highest availability",
+ "info1": "Hover or tap the calendar below to see who is available",
+ "info2": "Click the names below to view people individually"
+ },
+
+ "you": {
+ "info": "Click and drag the calendar below to set your availabilities",
+ "google_cal": {
+ "login": "Sync with Google Calendar",
+ "logout": "log out",
+ "select_all": "Select all",
+ "select_none": "Select none",
+ "info": "Importing will overwrite your current availability",
+ "button": "Import availability"
+ }
+ }
+}
diff --git a/crabfit-frontend/public/i18n/en-US/help.json b/crabfit-frontend/public/i18n/en-US/help.json
new file mode 100644
index 0000000..4d0f1c7
--- /dev/null
+++ b/crabfit-frontend/public/i18n/en-US/help.json
@@ -0,0 +1,23 @@
+{
+ "name": "How to Crab Fit",
+
+ "p1": "Crab Fit is a tool that helps you when planning events with friends or coworkers. You just create an event, enter your availability, send it out, and see when everyone is free!",
+ "p2": "See below for detailed steps of how to Crab Fit your event.",
+
+ "s1": "Step 1",
+
+ "p3": "Use the form at <1>crab.fit1> to make a new event. You only need to put in the rough time period for when your event occurs here, not your availability.",
+ "p4": "For example, we'll use \"Jenny's Birthday Lunch\". Jenny wants her birthday lunch to happen on the same week as her birthday, the 15th of April, but she knows that not all of her friends are available on the 15th. She also doesn't want to do it on the weekend.",
+ "p5": "Jenny also knows that since it's a lunch event, it can't start before 11am or go any later than 5pm.",
+
+ "s2": "Step 2",
+
+ "p6": "Enter your availability for the event you just created.",
+ "p7": "In our example, Jenny now puts in her availability for her birthday lunch. She is free all week, except after 3pm on Tuesday and Wednesday, and before 1pm on Friday.",
+
+ "s3": "Step 3",
+
+ "p8": "Send the link to everyone you want to come.",
+ "p9": "After Jenny has sent the link to her friends and waited for them to also fill out their availabilities, she can now easily see them all on the heatmap below and choose the darkest area for a time that suits everyone!",
+ "p10": "In this example, 1pm to 3pm on Friday the 16th works for all Jenny's friends."
+}
diff --git a/crabfit-frontend/public/i18n/en-US/home.json b/crabfit-frontend/public/i18n/en-US/home.json
new file mode 100644
index 0000000..6639efd
--- /dev/null
+++ b/crabfit-frontend/public/i18n/en-US/home.json
@@ -0,0 +1,57 @@
+{
+ "create": "CREATE A",
+ "recently_visited": "Recently visited",
+ "nav": {
+ "about": "About",
+ "donate": "Donate"
+ },
+ "form": {
+ "name": {
+ "label": "Give your event a name!",
+ "sublabel": "Or leave blank to generate one"
+ },
+ "dates": {
+ "label": "What dates might work?",
+ "sublabel": "Click and drag to select",
+ "options": {
+ "specific": "Specific dates",
+ "week": "Days of the week"
+ },
+ "tooltips": {
+ "previous": "Previous month",
+ "next": "Next month",
+ "today": "today"
+ }
+ },
+ "times": {
+ "label": "What times might work?",
+ "sublabel": "Click and drag to select a time range"
+ },
+ "timezone": {
+ "label": "And the timezone",
+ "defaultOption": "Select..."
+ },
+
+ "button": "Create",
+ "errors": {
+ "no_dates": "You haven't selected any dates!",
+ "same_times": "The start and end times can't be the same",
+ "no_time": "You don't have any time selected",
+ "unknown": "An error ocurred while creating the event. Please try again later."
+ }
+ },
+ "offline": "You can't create a Crab Fit when you don't have an internet connection. Please make sure you're connected.",
+
+ "about": {
+ "name": "About Crab Fit",
+ "events": "Events created",
+ "availabilities": "Availabilities entered",
+ "content": {
+ "p1": "Crab Fit helps you fit your event around everyone's schedules. Simply create an event above and send the link to everyone that is participating. Results update live and you will be able to see a heat-map of when everyone is free.<1/><2>Learn more about how to Crab Fit2>.",
+ "p2": "Create a lot of Crab Fits? Get the <1>Chrome extension1> or <3>Firefox extension3> for your browser! You can also download the <5>Android app5> to Crab Fit on the go.",
+ "p3": "Created by <1>Ben Grant1>, Crab Fit is the modern-day solution to your group event planning debates.",
+ "p4": "The code for Crab Fit is open source, if you find any issues or want to contribute, you can visit the <1>repository1>. By using Crab Fit you agree to the <3>privacy policy3>.",
+ "p5": "Crab Fit costs more than $100 per month to run. Consider donating below if it helped you out so it can stay free for everyone. 🦀"
+ }
+ }
+}
diff --git a/crabfit-frontend/public/i18n/en-US/privacy.json b/crabfit-frontend/public/i18n/en-US/privacy.json
new file mode 100644
index 0000000..0f7f917
--- /dev/null
+++ b/crabfit-frontend/public/i18n/en-US/privacy.json
@@ -0,0 +1,52 @@
+{
+ "name": "Privacy Policy",
+
+ "p1": "This SERVICE is provided by Benjamin Grant at no cost and is intended for use as is.",
+ "p2": "This page is used to inform visitors regarding the policies of the collection, use, and disclosure of Personal Information if using the Service.",
+ "p3": "If you choose to use the Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that is collected is used for providing and improving the Service. Your information will not be used or shared with anyone except as described in this Privacy Policy.",
+
+ "h1": "Information Collection and Use",
+
+ "p4": "The Service uses third party services that may collect information used to identify you.",
+ "p5": "Links to privacy policies of the third party service providers used by the Service:",
+ "link": "Google Play Services",
+
+ "h2": "Log Data",
+
+ "p6": "When you use the Service, in the case of an error, data and information is collected to improve the Service, which may include your IP address, device name, operating system version, app configuration and the time and date of the error.",
+
+ "h3": "Cookies",
+
+ "p7": "Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.",
+ "p8": "Cookies are used by Google Analytics to track you across the web and provide anonymous statistics to improve the Service.",
+
+ "h4": "Service Providers",
+
+ "p9": "Third-party companies may be employed for the following reasons:",
+ "l1": "To facilitate the Service",
+ "l2": "To provide the Service on our behalf",
+ "l3": "To perform Service-related services",
+ "l4": "To assist in analyzing how the Service is used",
+ "p10": "To perform these tasks, the third parties may have access to your Personal Information, but are obligated not to disclose or use this information for any purpose except the above.",
+
+ "h5": "Security",
+
+ "p11": "Personal Information that is shared via the Service is protected, however remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, so take care when sharing Personal Information.",
+
+ "h6": "Links to Other Sites",
+
+ "p12": "The Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by the Service. Therefore, you are advised to review the Privacy Policy of these websites.",
+
+ "h7": "Children's Privacy",
+
+ "p13": "The Service does not address anyone under the age of 13. Personally identifiable information is not knowingly collected from children under 13. If discovered that a child under 13 has provided the Service with personal information, such information will be immediately deleted from the servers. If you are a parent or guardian and you are aware that your child has provided the Service with personal information, please <1>contact us1> so that this information can be removed.",
+
+ "h8": "Changes to This Privacy Policy",
+
+ "p14": "This Privacy Policy may be updated from time to time. Thus, you are advised to review this page periodically for any changes.",
+ "p15": "This policy is effective as of 2021-04-20",
+
+ "h9": "Contact Us",
+
+ "p16": "If you have any questions or suggestions about the Privacy Policy, do not hesitate to contact us at <1>benjamin.grantGRA0007+crabfit@gmail.com1>."
+}
diff --git a/crabfit-frontend/src/App.tsx b/crabfit-frontend/src/App.tsx
index 2b4408f..ef16fa0 100644
--- a/crabfit-frontend/src/App.tsx
+++ b/crabfit-frontend/src/App.tsx
@@ -139,7 +139,9 @@ const App = () => {
)} />
-
+ }>
+
+
{eggVisible && setEggVisible(false)} />}
diff --git a/crabfit-frontend/src/components/AvailabilityEditor/AvailabilityEditor.tsx b/crabfit-frontend/src/components/AvailabilityEditor/AvailabilityEditor.tsx
index 5153588..9df7769 100644
--- a/crabfit-frontend/src/components/AvailabilityEditor/AvailabilityEditor.tsx
+++ b/crabfit-frontend/src/components/AvailabilityEditor/AvailabilityEditor.tsx
@@ -1,4 +1,5 @@
import { useState, useRef, Fragment } from 'react';
+import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import customParseFormat from 'dayjs/plugin/customParseFormat';
@@ -20,7 +21,7 @@ import {
} from 'components/AvailabilityViewer/availabilityViewerStyle';
import { Time } from './availabilityEditorStyle';
-import { GoogleCalendar } from 'components';
+import { GoogleCalendar, Center } from 'components';
dayjs.extend(localeData);
dayjs.extend(customParseFormat);
@@ -36,6 +37,7 @@ const AvailabilityEditor = ({
onChange,
...props
}) => {
+ const { t } = useTranslation('event');
const [selectingTimes, _setSelectingTimes] = useState([]);
const staticSelectingTimes = useRef([]);
const setSelectingTimes = newTimes => {
@@ -53,6 +55,9 @@ const AvailabilityEditor = ({
return (
<>
+
+
{
/>
{
type="submit"
isLoading={isLoginLoading}
disabled={isLoginLoading || isLoading}
- >Login
+ >{t('event:form.button')}
{error && setError(null)}>{error}}
- These details are only for this event. Use a password to prevent others from changing your availability.
+ {t('event:form.info')}
>
)}
{
options={timezones}
/>
{/* eslint-disable-next-line */}
- {event?.timezone && event.timezone !== timezone &&
Crab Fit is a tool that helps you when planning events with friends or coworkers. You just create an event, enter your availability, send it out, and see when everyone is free!
-
See below for detailed steps of how to Crab Fit your event.
+
{t('help:name')}
+
{t('help:p1')}
+
{t('help:p2')}
- Step 1
-
Use the form at crab.fit to make a new event. You only need to put in the rough time period for when your event occurs here, not your availability.
-
For example, we'll use "Jenny's Birthday Lunch". Jenny wants her birthday lunch to happen on the same week as her birthday, the 15th of April, but she knows that not all of her friends are available on the 15th. She also doesn't want to do it on the weekend.
+ {t('help:s1')}
+
Use the form at crab.fit to make a new event. You only need to put in the rough time period for when your event occurs here, not your availability.
+
{t('help:p4')}
SunMonTueWedThuFriSat
11121314151617
-
Jenny also knows that since it's a lunch event, it can't start before 11am or go any later than 5pm.
+
{t('help:p5')}
- Step 2
-
Enter your availability for the event you just created.
-
In our example, Jenny now puts in her availability for her birthday lunch. She is free all week, except after 3pm on Tuesday and Wednesday, and before 1pm on Friday.
+ {t('help:s2')}
+
{t('help:p6')}
+
{t('help:p7')}
{
max={1}
/>
- Step 3
-
Send the link to everyone you want to come.
-
After Jenny has sent the link to her friends and waited for them to also fill out their availabilities, she can now easily see them all on the heatmap below and choose the darkest area for a time that suits everyone!
-
In this example, 1pm to 3pm on Friday the 16th works for all Jenny's friends.
+ {t('help:s3')}
+
{t('help:p8')}
+
{t('help:p9')}
+
{t('help:p10')}
{
-
push('/')}>Create your own Crab Fit!
+
push('/')}>{t('common:cta')}
diff --git a/crabfit-frontend/src/pages/Home/Home.tsx b/crabfit-frontend/src/pages/Home/Home.tsx
index 2c2870a..94552cc 100644
--- a/crabfit-frontend/src/pages/Home/Home.tsx
+++ b/crabfit-frontend/src/pages/Home/Home.tsx
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useHistory, Link } from 'react-router-dom';
import { useForm } from 'react-hook-form';
+import { useTranslation, Trans } from 'react-i18next';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
@@ -60,6 +61,7 @@ const Home = ({ offline }) => {
});
const { push } = useHistory();
const recentsStore = useRecentsStore();
+ const { t } = useTranslation(['common', 'home']);
useEffect(() => {
const fetch = async () => {
@@ -152,17 +154,17 @@ const Home = ({ offline }) => {
Crab Fit helps you fit your event around everyone's schedules. Simply create an event above and send the link to everyone that is participating. Results update live and you will be able to see a heat-map of when everyone is free. Learn more about how to Crab Fit.
+
Crab Fit helps you fit your event around everyone's schedules. Simply create an event above and send the link to everyone that is participating. Results update live and you will be able to see a heat-map of when everyone is free. Learn more about how to Crab Fit.
Created by Ben Grant, Crab Fit is the modern-day solution to your group event planning debates.
-
The code for Crab Fit is open source, if you find any issues or want to contribute, you can visit the repository. By using Crab Fit you agree to the privacy policy.
-
Crab Fit costs more than $100 per month to run. Consider donating below if it helped you out so it can stay free for everyone. 🦀
+
Created by Ben Grant, Crab Fit is the modern-day solution to your group event planning debates.
+
The code for Crab Fit is open source, if you find any issues or want to contribute, you can visit the repository. By using Crab Fit you agree to the privacy policy.
+
Crab Fit costs more than $100 per month to run. Consider donating below if it helped you out so it can stay free for everyone. 🦀
This SERVICE is provided by Benjamin Grant at no cost and is intended for use as is.
-
This page is used to inform visitors regarding the policies of the collection, use, and disclosure of Personal Information if using the Service.
-
If you choose to use the Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that is collected is used for providing and improving the Service. Your information will not be used or shared with anyone except as described in this Privacy Policy.
+
{t('privacy:p1')}
+
{t('privacy:p2')}
+
{t('privacy:p3')}
-
Information Collection and Use
-
The Service uses third party services that may collect information used to identify you.
-
Links to privacy policies of the third party service providers used by the Service:
When you use the Service, in the case of an error, data and information is collected to improve the Service, which may include your IP address, device name, operating system version, app configuration and the time and date of the error.
+
{t('privacy:h2')}
+
{t('privacy:p6')}
-
Cookies
-
Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
-
Cookies are used by Google Analytics to track you across the web and provide anonymous statistics to improve the Service.
+
{t('privacy:h3')}
+
{t('privacy:p7')}
+
{t('privacy:p8')}
-
Service Providers
-
Third-party companies may be employed for the following reasons:
+
{t('privacy:h4')}
+
{t('privacy:p9')}
-
To facilitate the Service
-
To provide the Service on our behalf
-
To perform Service-related services
-
To assist in analyzing how the Service is used
+
{t('privacy:l1')}
+
{t('privacy:l2')}
+
{t('privacy:l3')}
+
{t('privacy:l4')}
-
To perform these tasks, the third parties may have access to your Personal Information, but are obligated not to disclose or use this information for any purpose except the above.
+
{t('privacy:p10')}
-
Security
-
Personal Information that is shared via the Service is protected, however remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, so take care when sharing Personal Information.
+
{t('privacy:h5')}
+
{t('privacy:p11')}
-
Links to Other Sites
-
The Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by the Service. Therefore, you are advised to review the Privacy Policy of these websites.
+
{t('privacy:h6')}
+
{t('privacy:p12')}
-
Children's Privacy
-
The Service does not address anyone under the age of 13. Personally identifiable information is not knowingly collected from children under 13. If discovered that a child under 13 has provided the Service with personal information, such information will be immediately deleted from the servers. If you are a parent or guardian and you are aware that your child has provided the Service with personal information, please contact us so that this information can be removed.
+
{t('privacy:h7')}
+
The Service does not address anyone under the age of 13. Personally identifiable information is not knowingly collected from children under 13. If discovered that a child under 13 has provided the Service with personal information, such information will be immediately deleted from the servers. If you are a parent or guardian and you are aware that your child has provided the Service with personal information, please contact us so that this information can be removed.
-
Changes to This Privacy Policy
-
This Privacy Policy may be updated from time to time. Thus, you are advised to review this page periodically for any changes.