From bee41b242bc16654a3180fdba4259d8a484cdc40 Mon Sep 17 00:00:00 2001 From: Mihai C <34626017+mihaic195@users.noreply.github.com> Date: Wed, 13 Oct 2021 12:34:55 +0300 Subject: [PATCH] chore: extract more strings (#933) --- components/SettingsShell.tsx | 14 ++-- components/security/TwoFactorAuthSection.tsx | 4 +- pages/settings/billing.tsx | 27 +++++--- pages/settings/embed.tsx | 63 ++++++++++-------- pages/settings/profile.tsx | 70 +++++++++----------- pages/settings/security.tsx | 1 - pages/settings/teams.tsx | 20 +++--- public/static/locales/en/common.json | 46 ++++++++++--- 8 files changed, 146 insertions(+), 99 deletions(-) diff --git a/components/SettingsShell.tsx b/components/SettingsShell.tsx index 04c91170..eb6f2945 100644 --- a/components/SettingsShell.tsx +++ b/components/SettingsShell.tsx @@ -1,28 +1,32 @@ import { CodeIcon, CreditCardIcon, KeyIcon, UserGroupIcon, UserIcon } from "@heroicons/react/solid"; import React from "react"; +import { useLocale } from "@lib/hooks/useLocale"; + import NavTabs from "./NavTabs"; export default function SettingsShell({ children }: { children: React.ReactNode }) { + const { t } = useLocale(); + const tabs = [ { - name: "Profile", + name: t("profile"), href: "/settings/profile", icon: UserIcon, }, { - name: "Security", + name: t("security"), href: "/settings/security", icon: KeyIcon, }, - { name: "Embed & Webhooks", href: "/settings/embed", icon: CodeIcon }, + { name: t("embed_and_webhooks"), href: "/settings/embed", icon: CodeIcon }, { - name: "Teams", + name: t("teams"), href: "/settings/teams", icon: UserGroupIcon, }, { - name: "Billing", + name: t("billing"), href: "/settings/billing", icon: CreditCardIcon, }, diff --git a/components/security/TwoFactorAuthSection.tsx b/components/security/TwoFactorAuthSection.tsx index cc16c424..888d3d2e 100644 --- a/components/security/TwoFactorAuthSection.tsx +++ b/components/security/TwoFactorAuthSection.tsx @@ -19,7 +19,7 @@ const TwoFactorAuthSection = ({ twoFactorEnabled }: { twoFactorEnabled: boolean

{t("2fa")}

- {enabled ? "Enabled" : "Disabled"} + {enabled ? t("enabled") : t("disabled")}

{t("add_an_extra_layer_of_security")}

@@ -28,7 +28,7 @@ const TwoFactorAuthSection = ({ twoFactorEnabled }: { twoFactorEnabled: boolean className="mt-6" type="submit" onClick={() => (enabled ? setDisableModalOpen(true) : setEnableModalOpen(true))}> - {enabled ? "Disable" : "Enable"} {t("2fa")} + {enabled ? t("disable") : t("enable")} {t("2fa")} {enableModalOpen && ( diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx index 02b9a0cb..a6ce3664 100644 --- a/pages/settings/billing.tsx +++ b/pages/settings/billing.tsx @@ -1,7 +1,10 @@ import { ExternalLinkIcon } from "@heroicons/react/solid"; import { GetServerSidePropsContext } from "next"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; 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 SettingsShell from "@components/SettingsShell"; @@ -9,24 +12,26 @@ import Shell from "@components/Shell"; import Button from "@components/ui/Button"; export default function Billing() { + const { t } = useLocale(); + return ( - +

- View and manage your billing details + {t("view_and_manage_billing_details")}

-

View and edit your billing details, as well as cancel your subscription.

+

{t("view_and_edit_billing_details")}

@@ -34,13 +39,13 @@ export default function Billing() {
-

Need anything else?

+

{t("need_anything_else")}

-

If you need any further help with billing, our support team are here to help.

+

{t("further_billing_help")}

@@ -53,6 +58,8 @@ export default function Billing() { export async function getServerSideProps(context: GetServerSidePropsContext) { const session = await getSession(context); + const locale = await getOrSetUserLocaleFromHeaders(context.req); + if (!session) { return { redirect: { permanent: false, destination: "/auth/login" } }; } @@ -74,6 +81,10 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { }); return { - props: { session, user }, + props: { + session, + user, + ...(await serverSideTranslations(locale, ["common"])), + }, }; } diff --git a/pages/settings/embed.tsx b/pages/settings/embed.tsx index d3525c1b..8b8044c0 100644 --- a/pages/settings/embed.tsx +++ b/pages/settings/embed.tsx @@ -1,9 +1,12 @@ import { PlusIcon } from "@heroicons/react/outline"; import { GetServerSidePropsContext } from "next"; import { useSession } from "next-auth/client"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { useEffect, useState, useRef } 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"; import { Webhook } from "@lib/webhook"; @@ -19,6 +22,7 @@ import WebhookList from "@components/webhook/WebhookList"; export default function Embed(props: inferSSRProps) { const [, loading] = useSession(); + const { t } = useLocale(); const [isLoading, setLoading] = useState(false); const [bookingCreated, setBookingCreated] = useState(true); @@ -52,7 +56,9 @@ export default function Embed(props: inferSSRProps) { } const iframeTemplate = ``; - const htmlTemplate = `Schedule a meeting${iframeTemplate}`; + const htmlTemplate = `${t( + "schedule_a_meeting" + )}${iframeTemplate}`; const handleErrors = async (resp: Response) => { if (!resp.ok) { const err = await resp.json(); @@ -106,26 +112,24 @@ export default function Embed(props: inferSSRProps) { }; return ( - + {!editWebhookEnabled && (
-

iframe Embed

-

The easiest way to embed Cal.com on your website.

+

{t("iframe_embed")}

+

{t("embed_calcom")}

@@ -276,7 +272,7 @@ export default function Settings(props: Props) { @@ -285,7 +281,7 @@ export default function Settings(props: Props) {
diff --git a/public/static/locales/en/common.json b/public/static/locales/en/common.json index ee491e79..26763e93 100644 --- a/public/static/locales/en/common.json +++ b/public/static/locales/en/common.json @@ -1,4 +1,34 @@ { + "light": "Light", + "dark": "Dark", + "automatically_adjust_theme": "Automatically adjust theme based on invitee preferences", + "email": "Email", + "full_name": "Full name", + "browse_api_documentation": "Browse our API documentation", + "leverage_our_api": "Leverage our API for full control and customizability.", + "create_webhook": "Create Webhook", + "booking_cancelled": "Booking Cancelled", + "booking_rescheduled": "Booking Rescheduled", + "booking_created": "Booking Created", + "event_triggers": "Event triggers", + "subscriber_url": "Subscriber Url", + "create_new_webhook": "Create a new webhook", + "create_new_webhook_to_account": "Create a new webhook to your account", + "new_webhook": "New Webhook", + "receive_cal_meeting_data": "Receive Cal meeting data at a specified URL, in real-time, when an event is scheduled or cancelled.", + "responsive_fullscreen_iframe": "Responsive full screen iframe", + "loading": "Loading...", + "standard_iframe": "Standard iframe", + "iframe_embed": "iframe Embed", + "embed_calcom": "The easiest way to embed Cal.com on your website.", + "integrate_using_embed_or_webhooks": "Integrate with your website using our embed options, or get real-time booking information using custom webhooks.", + "schedule_a_meeting": "Schedule a meeting", + "view_and_manage_billing_details": "View and manage your billing details", + "view_and_edit_billing_details": "View and edit your billing details, as well as cancel your subscription.", + "go_to_billing_portal": "Go to the billing portal", + "need_anything_else": "Need anything else?", + "further_billing_help": "If you need any further help with billing, our support team are here to help.", + "contact_our_support_team": "Contact our support team", "uh_oh": "Uh oh!", "no_event_types_have_been_setup": "This user hasn't set up any event types yet.", "edit_logo": "Edit logo", @@ -147,26 +177,25 @@ "new_event_description": "Create a new event type for people to book times with.", "event_type_created_successfully": "{{eventTypeTitle}} event type created successfully", "hours": "Hours", - "full_name": "Full Name", "your_email": "Your Email", "change_avatar": "Change Avatar", "language": "Language", "timezone": "Timezone", - "first_day_week": "First day week", + "first_day_of_week": "First Day of Week", "single_theme": "Single Theme", "file_not_named": "File is not named [idOrSlug]/[user]", "create_team": "Create Team", - "name_team": "Name", + "name": "Name", "create_new_team_description": "Create a new team to collaborate with users.", "create_new_team": "Create a new team", "open_invitations": "Open Invitations", "new_team": "New Team", - "create_first_invite_other_users": "Create your first team and invite other users to work together with you.", - "create_team_get_started": "Create a team to get started", + "create_first_team_and_invite_others": "Create your first team and invite other users to work together with you.", + "create_team_to_get_started": "Create a team to get started", "teams": "Teams", "create_manage_teams_collaborative": "Create and manage teams to use collaborative features.", - "this_feature_only_available_paid_plan": "This feature is only available in paid plan", - "order_remove_cal_branding_description": "In order to remove the Cal branding from your booking pages, you need to upgrade to a paid account.", + "only_available_on_pro_plan": "This feature is only available in Pro plan", + "remove_cal_branding_description": "In order to remove the Cal branding from your booking pages, you need to upgrade to a Pro account.", "to_upgrade_go_to": "To upgrade go to", "edit_profile_info_description": "Edit your profile information, which shows on your scheduling link.", "change_email_contact": "To change your email, please contact", @@ -174,9 +203,10 @@ "profile_updated_successfully": "Profile updated successfully", "your_user_profile_updated_successfully": "Your user profile has been updated successfully.", "user_cannot_found_db": "User seems logged in but cannot be found in the db", - "embed_and_webhooks": "Embed & Webhooks", + "embed_and_webhooks": "Embed & Webhooks", "enabled": "Enabled", "disabled": "Disabled", + "disable": "Disable", "billing": "Billing", "manage_your_billing_info": "Manage your billing information and cancel your subscription.", "availability": "Availability",