From 9e2f8de313b872eb1caca4918c110849dc3f028f Mon Sep 17 00:00:00 2001
From: Mihai C <34626017+mihaic195@users.noreply.github.com>
Date: Wed, 13 Oct 2021 13:49:15 +0300
Subject: [PATCH] chore: i18n/extract strings (#934)
---
pages/availability/index.tsx | 54 ++++++++++++++--------------
pages/availability/troubleshoot.tsx | 33 ++++++++++-------
pages/bookings/[status].tsx | 24 ++++++++-----
pages/call/no-meeting-found.tsx | 14 ++++----
pages/cancel/[uid].tsx | 26 ++++++++------
pages/cancel/success.tsx | 14 +++++---
public/static/locales/en/common.json | 46 ++++++++++++++++++++++--
7 files changed, 139 insertions(+), 72 deletions(-)
diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx
index 3b9df01c..f73d24c8 100644
--- a/pages/availability/index.tsx
+++ b/pages/availability/index.tsx
@@ -4,6 +4,7 @@ import { useRouter } from "next/router";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
+import { useLocale } from "@lib/hooks/useLocale";
import { useToggleQuery } from "@lib/hooks/useToggleQuery";
import showToast from "@lib/notification";
import { trpc } from "@lib/trpc";
@@ -22,6 +23,7 @@ function convertMinsToHrsMins(mins: number) {
return `${hours}:${minutes}`;
}
export default function Availability() {
+ const { t } = useLocale();
const queryMe = trpc.useQuery(["viewer.me"]);
const formModal = useToggleQuery("edit");
@@ -57,27 +59,25 @@ export default function Availability() {
return ;
}
if (queryMe.status !== "success") {
- return ;
+ return ;
}
const user = queryMe.data;
return (
-
+
-
- Change the start and end times of your day
-
+
{t("change_start_end")}
- Currently, your day is set to start at {convertMinsToHrsMins(user.startTime)} and end at{" "}
+ {t("current_start_date")} {convertMinsToHrsMins(user.startTime)} {t("and_end_at")}{" "}
{convertMinsToHrsMins(user.endTime)}.
-
+
@@ -85,14 +85,14 @@ export default function Availability() {
@@ -111,12 +111,10 @@ export default function Availability() {
- Change your available times
+ {t("change_your_available_times")}
-
- Set the start and end time of your day and a minimum buffer between your meetings.
-
+
{t("change_start_end_buffer")}
@@ -136,19 +134,21 @@ export default function Availability() {
},
});
if (!response.ok) {
- showToast("Something went wrong", "error");
+ showToast(t("something_went_wrong"), "error");
return;
}
await queryMe.refetch();
router.push(formModal.hrefOff);
- showToast("The start and end times for your day have been changed successfully.", "success");
+ showToast(t("start_end_changed_successfully"), "success");
})}>
-
+
:
-
+
:
-
+
:
diff --git a/pages/availability/troubleshoot.tsx b/pages/availability/troubleshoot.tsx
index 64c6173d..9bdd3b6f 100644
--- a/pages/availability/troubleshoot.tsx
+++ b/pages/availability/troubleshoot.tsx
@@ -1,9 +1,12 @@
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import { GetServerSidePropsContext } from "next";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useEffect, useState } from "react";
import { getSession } from "@lib/auth";
+import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
+import { useLocale } from "@lib/hooks/useLocale";
import prisma from "@lib/prisma";
import { inferSSRProps } from "@lib/types/inferSSRProps";
@@ -13,6 +16,7 @@ import Shell from "@components/Shell";
dayjs.extend(utc);
export default function Troubleshoot({ user }: inferSSRProps) {
+ const { t } = useLocale();
const [loading, setLoading] = useState(true);
const [availability, setAvailability] = useState([]);
const [selectedDate, setSelectedDate] = useState(dayjs());
@@ -52,12 +56,10 @@ export default function Troubleshoot({ user }: inferSSRProps
-
+
- Here is an overview of your day on{" "}
+ {t("overview_of_day")}{" "}
-
- Tip: Hover over the bold times for a full timestamp
-
+ {t("hover_over_bold_times_tip")}
- Your day starts at {convertMinsToHrsMins(user.startTime)}
+ {t("your_day_starts_at")} {convertMinsToHrsMins(user.startTime)}
{availability.map((slot) => (
- Your calendar shows you as busy between{" "}
+ {t("calendar_shows_busy_between")}{" "}
{dayjs(slot.start).format("HH:mm")}
{" "}
- and{" "}
+ {t("and")}{" "}
{dayjs(slot.end).format("HH:mm")}
{" "}
- on {dayjs(slot.start).format("D MMMM YYYY")}
+ {t("on")} {dayjs(slot.start).format("D")}{" "}
+ {t(dayjs(slot.start).format("MMMM").toLowerCase())} {dayjs(slot.start).format("YYYY")}
))}
{availability.length === 0 && }
- Your day ends at {convertMinsToHrsMins(user.endTime)}
+ {t("your_day_ends_at")} {convertMinsToHrsMins(user.endTime)}
@@ -106,6 +107,8 @@ export default function Troubleshoot({ user }: inferSSRProps {
const session = await getSession(context);
+ const locale = await getOrSetUserLocaleFromHeaders(context.req);
+
if (!session?.user?.id) {
return { redirect: { permanent: false, destination: "/auth/login" } };
}
@@ -124,6 +127,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
if (!user) return { redirect: { permanent: false, destination: "/auth/login" } };
return {
- props: { session, user },
+ props: {
+ session,
+ user,
+ ...(await serverSideTranslations(locale, ["common"])),
+ },
};
};
diff --git a/pages/bookings/[status].tsx b/pages/bookings/[status].tsx
index b1b72b9e..6feaa6d5 100644
--- a/pages/bookings/[status].tsx
+++ b/pages/bookings/[status].tsx
@@ -2,6 +2,7 @@ import { CalendarIcon } from "@heroicons/react/outline";
import { useRouter } from "next/router";
import { QueryCell } from "@lib/QueryCell";
+import { useLocale } from "@lib/hooks/useLocale";
import { inferQueryInput, trpc } from "@lib/trpc";
import BookingsShell from "@components/BookingsShell";
@@ -11,19 +12,21 @@ import BookingListItem from "@components/booking/BookingListItem";
type BookingListingStatus = inferQueryInput<"viewer.bookings">["status"];
-const descriptionByStatus: Record = {
- upcoming: "As soon as someone books a time with you it will show up here.",
- past: "Your past bookings will show up here.",
- cancelled: "Your cancelled bookings will show up here.",
-};
-
export default function Bookings() {
+ const { t } = useLocale();
+
+ const descriptionByStatus: Record = {
+ upcoming: t("upcoming_bookings"),
+ past: t("past_bookings"),
+ cancelled: t("cancelled_bookings"),
+ };
+
const router = useRouter();
const status = router.query?.status as BookingListingStatus;
const query = trpc.useQuery(["viewer.bookings", { status }]);
return (
-
+
@@ -44,8 +47,11 @@ export default function Bookings() {
empty={() => (
)}
/>
diff --git a/pages/call/no-meeting-found.tsx b/pages/call/no-meeting-found.tsx
index aaebfb51..2328d194 100644
--- a/pages/call/no-meeting-found.tsx
+++ b/pages/call/no-meeting-found.tsx
@@ -1,13 +1,17 @@
import { XIcon } from "@heroicons/react/outline";
import { ArrowRightIcon } from "@heroicons/react/solid";
+import { useLocale } from "@lib/hooks/useLocale";
+
import { HeadSeo } from "@components/seo/head-seo";
import Button from "@components/ui/Button";
export default function NoMeetingFound() {
+ const { t } = useLocale();
+
return (
-
+
@@ -26,19 +30,17 @@ export default function NoMeetingFound() {
- No Meeting Found
+ {t("no_meeting_found")}
-
- This meeting does not exist. Contact the meeting owner for an updated link.
-
+
{t("no_meeting_found_description")}
diff --git a/pages/cancel/[uid].tsx b/pages/cancel/[uid].tsx
index 46746850..00aa8b82 100644
--- a/pages/cancel/[uid].tsx
+++ b/pages/cancel/[uid].tsx
@@ -2,9 +2,12 @@ import { CalendarIcon, XIcon } from "@heroicons/react/solid";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import { getSession } from "next-auth/client";
+import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useRouter } from "next/router";
import { useState } from "react";
+import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
+import { useLocale } from "@lib/hooks/useLocale";
import prisma from "@lib/prisma";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
@@ -14,6 +17,7 @@ import { Button } from "@components/ui/Button";
dayjs.extend(utc);
export default function Type(props) {
+ const { t } = useLocale();
// Get router variables
const router = useRouter();
const { uid } = router.query;
@@ -21,7 +25,7 @@ export default function Type(props) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [is24h, setIs24h] = useState(false);
const [loading, setLoading] = useState(false);
- const [error, setError] = useState(props.booking ? null : "This booking was already cancelled");
+ const [error, setError] = useState(props.booking ? null : t("booking_already_cancelled"));
const telemetry = useTelemetry();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -52,15 +56,15 @@ export default function Type(props) {
);
} else {
setLoading(false);
- setError("An error with status code " + res.status + " occurred. Please try again later.");
+ setError(`${t("error_with_status_code_occured", { status: res.status })} ${t("please_try_again")}`);
}
};
return (
@@ -95,14 +99,12 @@ export default function Type(props) {
{props.cancellationAllowed
- ? "Really cancel your booking?"
- : "You cannot cancel this booking"}
+ ? t("really_cancel_booking")
+ : t("cannot_cancel_booking")}
- {props.cancellationAllowed
- ? "Instead, you could also reschedule it."
- : "The event is in the past"}
+ {props.cancellationAllowed ? t("reschedule_instead") : t("event_is_in_the_past")}
diff --git a/public/static/locales/en/common.json b/public/static/locales/en/common.json
index 26763e93..6f489927 100644
--- a/public/static/locales/en/common.json
+++ b/public/static/locales/en/common.json
@@ -1,4 +1,45 @@
{
+ "back_to_bookings": "Back to bookings",
+ "free_to_pick_another_event_type": "Feel free to pick another event anytime.",
+ "cancelled": "Cancelled",
+ "cancellation_successful": "Cancellation successful",
+ "really_cancel_booking": "Really cancel your booking?",
+ "cannot_cancel_booking": "You cannot cancel this booking",
+ "reschedule_instead": "Instead, you could also reschedule it.",
+ "event_is_in_the_past": "The event is in the past",
+ "error_with_status_code_occured": "An error with status code {{status}} occurred.",
+ "booking_already_cancelled": "This booking was already cancelled",
+ "go_back_home": "Go back home",
+ "no_meeting_found": "No Meeting Found",
+ "no_meeting_found_description": "This meeting does not exist. Contact the meeting owner for an updated link.",
+ "no_status_bookings_yet": "No {{status}} bookings, yet",
+ "no_status_bookings_yet_description": "You have no {{status}} bookings. {{description}}",
+ "bookings": "Bookings",
+ "bookings_description": "See upcoming and past events booked through your event type links.",
+ "upcoming_bookings": "As soon as someone books a time with you it will show up here.",
+ "past_bookings": "Your past bookings will show up here.",
+ "cancelled_bookings": "Your cancelled bookings will show up here.",
+ "on": "on",
+ "and": "and",
+ "calendar_shows_busy_between": "Your calendar shows you as busy between",
+ "troubleshoot": "Troubleshoot",
+ "troubleshoot_description": "Understand why certain times are available and others are blocked.",
+ "overview_of_day": "Here is an overview of your day on",
+ "hover_over_bold_times_tip": "Tip: Hover over the bold times for a full timestamp",
+ "start_time": "Start time",
+ "end_time": "End time",
+ "buffer": "Buffer",
+ "your_day_starts_at": "Your day starts at",
+ "your_day_ends_at": "Your day ends at",
+ "launch_troubleshooter": "Launch troubleshooter",
+ "troubleshoot_availability": "Troubleshoot your availability to explore why your times are showing as they are.",
+ "change_available_times": "Change available times",
+ "change_your_available_times": "Change your available times",
+ "change_start_end": "Change the start and end times of your day",
+ "change_start_end_buffer": "Set the start and end time of your day and a minimum buffer between your meetings.",
+ "current_start_date": "Currently, your day is set to start at",
+ "start_end_changed_successfully": "The start and end times for your day have been changed successfully.",
+ "and_end_at": "and end at",
"light": "Light",
"dark": "Dark",
"automatically_adjust_theme": "Automatically adjust theme based on invitee preferences",
@@ -50,6 +91,7 @@
"password_has_been_changed": "Your password has been successfully changed.",
"error_changing_password": "Error changing password",
"something_went_wrong": "Something went wrong",
+ "something_doesnt_look_right": "Something doesn't look right?",
"please_try_again": "Please try again",
"super_secure_new_password": "Your super secure new password",
"new_password": "New Password",
@@ -158,7 +200,7 @@
"collective": "Collective",
"collective_description": "Schedule meetings when all selected team members are available.",
"duration": "Duration",
- "minutes": "minutes",
+ "minutes": "Minutes",
"round_robin": "Round Robin",
"round_robin_description": "Cycle meetings between multiple team members.",
"url": "URL",
@@ -210,7 +252,7 @@
"billing": "Billing",
"manage_your_billing_info": "Manage your billing information and cancel your subscription.",
"availability": "Availability",
- "configure_times_available_bookings": "Configure times when you are available for bookings.",
+ "configure_availability": "Configure times when you are available for bookings.",
"change_weekly_schedule": "Change your weekly schedule",
"logo": "Logo",
"error": "Error",