Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/src/packages/next/pages/lang/index.tsx
Views: 791
/*1* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Layout, List, Typography } from "antd";67import { GetServerSidePropsContext } from "next";89import { getI18nMessages } from "locales/lib";10import { LOCALE, query2locale } from "locales/misc";1112// The I18nProvider is either english by default, or based on the query path: /lang/[locale]13import I18nProvider from "next-translate/I18nProvider";1415import { Icon } from "@cocalc/frontend/components/icon";16import { LOCALIZATIONS } from "@cocalc/util/i18n";1718import Footer from "components/landing/footer";19import Head from "components/landing/head";20import Header from "components/landing/header";21import { Paragraph, Title } from "components/misc";22import A from "components/misc/A";23import { MAX_WIDTH } from "lib/config";24import { Customize } from "lib/customize";25import withCustomize from "lib/with-customize";2627function Index({ customize }) {28const { siteName } = customize;2930const links = LOCALE.map((locale, idx) => {31const l = LOCALIZATIONS[locale];32return {33locale,34content: [35l.flag,36<A key={idx} href={`/${locale}`}>37<strong>{l.native}</strong> – {l.name}38</A>,39],40};41})42.sort((a, b) =>43LOCALIZATIONS[a.locale].name.localeCompare(LOCALIZATIONS[b.locale].name),44)45.map((item) => item.content);4647return (48<>49<Head title={`Translations – ${siteName}`} />50<Layout>51<Header />52<Layout.Content style={{ backgroundColor: "white" }}>53<div54style={{55maxWidth: MAX_WIDTH,56margin: "15px auto",57padding: "15px",58backgroundColor: "white",59}}60>61<Title level={1}>62<Icon name="global" /> Translations63</Title>64<Paragraph>65<List66header={67<>68<Paragraph>69We offer a dedicated landing page that provides an70overview of {siteName}, available in several languages.71Please note that all other pages are currently available72only in English – including the{" "}73<A href={"/"}>main landing page</A>.74</Paragraph>75<Paragraph>76Note: There is an ongoing effort to provide {siteName}'s77main application in all these languages as well!78</Paragraph>79</>80}81dataSource={links}82bordered83renderItem={(item) => (84<List.Item>85<Typography.Text mark>{item[0]}</Typography.Text> {item[1]}86</List.Item>87)}88/>89</Paragraph>90</div>91<Footer />92</Layout.Content>93</Layout>94</>95);96}9798export default function I18NIndexPage({ customize, locale, messages }) {99return (100<Customize value={customize}>101<I18nProvider lang={locale} namespaces={messages}>102<Index customize={customize} />103</I18nProvider>104</Customize>105);106}107108export async function getServerSideProps(context: GetServerSidePropsContext) {109const locale = query2locale(context.query);110const messages = await getI18nMessages(locale);111112return withCustomize({113context,114props: { locale, messages },115});116}117118119