Feat/i18n crowdin (#752)

* feat: add crowdin and supported languages

* fix: main branch name

* feat: test crowdin integration

* feat: add crowdin config skeleton

* feat: update crowdin.yml

* fix: remove ro translation

* test: en translation

* test: en translation

* New Crowdin translations by Github Action (#735)

Co-authored-by: Crowdin Bot <[email protected]>

* test: en translation

* fix: separate upload/download workflows

* wip

* New Crowdin translations by Github Action (#738)

Co-authored-by: Crowdin Bot <[email protected]>

* wip

* wip

* wip

* wip

* wip

* typo

* wip

* wip

* update crowdin config

* update

* chore: support i18n de,es,fr,it,pt,ru,ro,en

* chore: extract i18n strings

* chore: extract booking components strings for i18n

* wip

* extract more strings

* wip

* fallback to getServerSideProps for now

* New Crowdin translations by Github Action (#874)

Co-authored-by: Crowdin Bot <[email protected]>

* fix: minor fixes on the datepicker

* fix: add dutch lang

* fix: linting issues

* fix: string

* fix: update GHA

* cleanup trpc

* fix linting

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Crowdin Bot <[email protected]>
Co-authored-by: Bailey Pumfleet <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-10-08 14:43:48 +03:00
1 parent 33a683d4b0
commit 2c9b301b77
46 files changed
+2805 -1876

No files matched your search

+7 -2
View File
@@ -7,7 +7,12 @@ import TimezoneSelect from "react-timezone-select";
import { asStringOrNull, asStringOrUndefined } from "@lib/asStringOrNull";
import { getSession } from "@lib/auth";
import { extractLocaleInfo, localeLabels, localeOptions, OptionType } from "@lib/core/i18n/i18n.utils";
import {
getOrSetUserLocaleFromHeaders,
localeLabels,
localeOptions,
OptionType,
} from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
import { isBrandingHidden } from "@lib/isBrandingHidden";
import prisma from "@lib/prisma";
@@ -416,7 +421,7 @@ export default function Settings(props: Props) {
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const session = await getSession(context);
const locale = await extractLocaleInfo(context.req);
const locale = await getOrSetUserLocaleFromHeaders(context.req);
if (!session?.user?.id) {
return { redirect: { permanent: false, destination: "/auth/login" } };
+17 -5
View File
@@ -1,6 +1,9 @@
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import React 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 SettingsShell from "@components/SettingsShell";
@@ -8,12 +11,14 @@ import Shell from "@components/Shell";
import ChangePasswordSection from "@components/security/ChangePasswordSection";
import TwoFactorAuthSection from "@components/security/TwoFactorAuthSection";
export default function Security({ user }) {
export default function Security({ user, localeProp }) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { locale, t } = useLocale({ localeProp });
return (
<Shell heading="Security" subtitle="Manage your account's security.">
<Shell heading={t("security")} subtitle={t("manage_account_security")}>
<SettingsShell>
<ChangePasswordSection />
<TwoFactorAuthSection twoFactorEnabled={user.twoFactorEnabled} />
<ChangePasswordSection localeProp={locale} />
<TwoFactorAuthSection localeProp={locale} twoFactorEnabled={user.twoFactorEnabled} />
</SettingsShell>
</Shell>
);
@@ -21,6 +26,8 @@ export default function Security({ user }) {
export async function getServerSideProps(context) {
const session = await getSession(context);
const locale = await getOrSetUserLocaleFromHeaders(context.req);
if (!session?.user?.id) {
return { redirect: { permanent: false, destination: "/auth/login" } };
}
@@ -38,6 +45,11 @@ export async function getServerSideProps(context) {
});
return {
props: { session, user },
props: {
localeProp: locale,
session,
user,
...(await serverSideTranslations(locale, ["common"])),
},
};
}
+18 -4
View File
@@ -3,9 +3,12 @@ import { PlusIcon } from "@heroicons/react/solid";
import { GetServerSideProps } from "next";
import type { Session } from "next-auth";
import { useSession } from "next-auth/client";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useEffect, useRef, useState } from "react";
import { getSession } from "@lib/auth";
import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
import { Member } from "@lib/member";
import { Team } from "@lib/team";
@@ -17,7 +20,7 @@ import TeamList from "@components/team/TeamList";
import TeamListItem from "@components/team/TeamListItem";
import Button from "@components/ui/Button";
export default function Teams() {
export default function Teams(props: { localeProp: string }) {
const noop = () => undefined;
const [, loading] = useSession();
const [teams, setTeams] = useState([]);
@@ -26,6 +29,7 @@ export default function Teams() {
const [editTeamEnabled, setEditTeamEnabled] = useState(false);
const [teamToEdit, setTeamToEdit] = useState<Team | null>();
const nameRef = useRef<HTMLInputElement>() as React.MutableRefObject<HTMLInputElement>;
const { locale } = useLocale({ localeProp: props.localeProp });
const handleErrors = async (resp: Response) => {
if (!resp.ok) {
@@ -110,7 +114,11 @@ export default function Teams() {
</div>
<div>
{!!teams.length && (
<TeamList teams={teams} onChange={loadData} onEditTeam={editTeam}></TeamList>
<TeamList
localeProp={locale}
teams={teams}
onChange={loadData}
onEditTeam={editTeam}></TeamList>
)}
{!!invites.length && (
@@ -119,6 +127,7 @@ export default function Teams() {
<ul className="px-4 mt-4 mb-2 bg-white border divide-y divide-gray-200 rounded">
{invites.map((team: Team) => (
<TeamListItem
localeProp={locale}
onChange={loadData}
key={team.id}
team={team}
@@ -131,7 +140,7 @@ export default function Teams() {
</div>
</div>
)}
{!!editTeamEnabled && <EditTeam team={teamToEdit} onCloseEdit={onCloseEdit} />}
{!!editTeamEnabled && <EditTeam localeProp={locale} team={teamToEdit} onCloseEdit={onCloseEdit} />}
{showCreateTeamModal && (
<div
className="fixed inset-0 z-50 overflow-y-auto"
@@ -200,11 +209,16 @@ export default function Teams() {
// Export the `session` prop to use sessions with Server Side Rendering
export const getServerSideProps: GetServerSideProps<{ session: Session | null }> = async (context) => {
const session = await getSession(context);
const locale = await getOrSetUserLocaleFromHeaders(context.req);
if (!session) {
return { redirect: { permanent: false, destination: "/auth/login" } };
}
return {
props: { session },
props: {
session,
localeProp: locale,
...(await serverSideTranslations(locale, ["common"])),
},
};
};